Add mock implementations

This commit is contained in:
Nick Alteen
2023-09-15 12:38:47 -04:00
parent ace81e8ec7
commit b77f506d20

View File

@@ -11,10 +11,10 @@ import * as main from '../src/main'
// Mock the GitHub Actions core library // Mock the GitHub Actions core library
//const debugMock = jest.spyOn(core, 'debug') //const debugMock = jest.spyOn(core, 'debug')
const infoMock = jest.spyOn(core, 'info') const infoMock = jest.spyOn(core, 'info').mockImplementation()
const getInputMock = jest.spyOn(core, 'getInput') const getInputMock = jest.spyOn(core, 'getInput').mockImplementation()
const setFailedMock = jest.spyOn(core, 'setFailed') const setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation()
const setOutputMock = jest.spyOn(core, 'setOutput') const setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()
// Mock the action's main function // Mock the action's main function
const runMock = jest.spyOn(main, 'run') const runMock = jest.spyOn(main, 'run')
@@ -57,16 +57,12 @@ describe('action', () => {
} }
}) })
try { await main.run()
await main.run()
expect(runMock).toHaveReturned() expect(runMock).toHaveReturned()
expect(setFailedMock).toHaveBeenNthCalledWith( expect(setFailedMock).toHaveBeenNthCalledWith(
1, 1,
'milliseconds not a number' 'milliseconds not a number'
) )
} catch (error) {
console.log(error)
}
}) })
}) })