Skip to content

Commit

Permalink
Add tests for core.setOutput
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonEtco committed Dec 5, 2019
1 parent eb3af37 commit 73b6555
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/index.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const nock = require('nock')
const core = require('@actions/core')
const { Toolkit } = require('actions-toolkit')

describe('create-an-issue', () => {
Expand Down Expand Up @@ -28,6 +29,10 @@ describe('create-an-issue', () => {
}
})

// Turn core.setOutput into a mocked noop
jest.spyOn(core, 'setOutput')
.mockImplementation(() => {})

tools.exit.success = jest.fn()
tools.exit.failure = jest.fn()

Expand All @@ -41,6 +46,11 @@ describe('create-an-issue', () => {
expect(params).toMatchSnapshot()
expect(tools.log.success).toHaveBeenCalled()
expect(tools.log.success.mock.calls).toMatchSnapshot()

// Verify that the outputs were set
expect(core.setOutput).toHaveBeenCalledTimes(2)
expect(core.setOutput).toHaveBeenCalledWith('url', 'www')
expect(core.setOutput).toHaveBeenCalledWith('number', 1)
})

it('creates a new issue from a different template', async () => {
Expand Down

0 comments on commit 73b6555

Please sign in to comment.