try body as file, use as string otherwise

This commit is contained in:
Jacob Bolda
2020-02-03 22:37:38 -06:00
parent 4d1b6075ce
commit bfe866faf6
4 changed files with 46 additions and 6 deletions

View File

@@ -1,8 +1,10 @@
jest.mock('@actions/core');
jest.mock('@actions/github');
jest.mock('fs');
const core = require('@actions/core');
const { GitHub, context } = require('@actions/github');
const fs = require('fs');
const run = require('../src/create-release.js');
/* eslint-disable no-undef */
@@ -120,6 +122,30 @@ describe('Create Release', () => {
});
});
test('Release body based on file', async () => {
core.getInput = jest
.fn()
.mockReturnValueOnce('refs/tags/v1.0.0')
.mockReturnValueOnce('myRelease')
.mockReturnValueOnce('notes.md')
.mockReturnValueOnce('false')
.mockReturnValueOnce('false');
fs.readFileSync = jest.fn().mockReturnValueOnce('# this is a release\nThe markdown is strong in this one.');
await run();
expect(createRelease).toHaveBeenCalledWith({
owner: 'owner',
repo: 'repo',
tag_name: 'v1.0.0',
name: 'myRelease',
body: '# this is a release\nThe markdown is strong in this one.',
draft: false,
prerelease: false
});
});
test('Outputs are set', async () => {
core.getInput = jest
.fn()