Create release endpoint test

This commit is contained in:
Thomas Hughes 2019-09-26 15:24:23 -05:00
parent 782415ab55
commit aa6f452281
No known key found for this signature in database
GPG Key ID: B2D8646423EF5814
3 changed files with 47 additions and 4 deletions

2
dist/index.js vendored
View File

@ -393,9 +393,9 @@ async function run() {
// Get the inputs from the workflow file: https://github.com/actions/toolkit/tree/master/packages/core#inputsoutputs
const tagName = core.getInput('tag_name', { required: true });
// This removes the 'refs/tags' portion of the string, i.e. from 'refs/tags/v1.10.15' to 'v1.10.15'
const tag = tagName.replace('refs/tags/', '');
// This removes the 'refs/tags' portion of the string, i.e. from 'refs/tags/v1.10.15' to 'v1.10.15'
const releaseName = core.getInput('release_name', { required: true }).replace('refs/tags/', '');
const draft = core.getInput('draft', { required: false }) === 'true';
const prerelease = core.getInput('prerelease', { required: false }) === 'true';

View File

@ -11,9 +11,9 @@ async function run() {
// Get the inputs from the workflow file: https://github.com/actions/toolkit/tree/master/packages/core#inputsoutputs
const tagName = core.getInput('tag_name', { required: true });
// This removes the 'refs/tags' portion of the string, i.e. from 'refs/tags/v1.10.15' to 'v1.10.15'
const tag = tagName.replace('refs/tags/', '');
// This removes the 'refs/tags' portion of the string, i.e. from 'refs/tags/v1.10.15' to 'v1.10.15'
const releaseName = core.getInput('release_name', { required: true }).replace('refs/tags/', '');
const draft = core.getInput('draft', { required: false }) === 'true';
const prerelease = core.getInput('prerelease', { required: false }) === 'true';

View File

@ -1,6 +1,49 @@
jest.mock('@actions/core');
jest.mock('@actions/github');
const core = require('@actions/core');
const { GitHub, context } = require('@actions/github');
const run = require('../src/main.js');
/* eslint-disable no-undef */
describe('Create release', () => {
test('Create release endpoint is called', async () => {});
describe('module', () => {
let createRelease;
beforeEach(() => {
core.getInput = jest.fn()
.mockReturnValueOnce('refs/tags/v1.0.0')
.mockReturnValueOnce('myRelease')
.mockReturnValueOnce('false')
.mockReturnValueOnce('false');
createRelease = jest.fn();
context.repo = {
owner: 'owner',
repo: 'repo'
};
const github = {
repos: {
createRelease
}
};
GitHub.mockImplementation(() => github);
});
test('Create release endpoint is called', async () => {
await run();
expect(createRelease).toHaveBeenCalledWith({
owner: 'owner',
repo: 'repo',
tag_name: 'v1.0.0',
name: 'myRelease',
draft: false,
prerelease: false
});
});
test('Outputs are set', async () => {});
});