mirror of
https://github.com/actions/container-toolkit-action.git
synced 2025-12-10 20:21:17 +00:00
Add mock implementations
This commit is contained in:
@@ -11,10 +11,10 @@ import * as main from '../src/main'
|
||||
|
||||
// Mock the GitHub Actions core library
|
||||
//const debugMock = jest.spyOn(core, 'debug')
|
||||
const infoMock = jest.spyOn(core, 'info')
|
||||
const getInputMock = jest.spyOn(core, 'getInput')
|
||||
const setFailedMock = jest.spyOn(core, 'setFailed')
|
||||
const setOutputMock = jest.spyOn(core, 'setOutput')
|
||||
const infoMock = jest.spyOn(core, 'info').mockImplementation()
|
||||
const getInputMock = jest.spyOn(core, 'getInput').mockImplementation()
|
||||
const setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation()
|
||||
const setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()
|
||||
|
||||
// Mock the action's main function
|
||||
const runMock = jest.spyOn(main, 'run')
|
||||
@@ -57,16 +57,12 @@ describe('action', () => {
|
||||
}
|
||||
})
|
||||
|
||||
try {
|
||||
await main.run()
|
||||
await main.run()
|
||||
|
||||
expect(runMock).toHaveReturned()
|
||||
expect(setFailedMock).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
'milliseconds not a number'
|
||||
)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
expect(runMock).toHaveReturned()
|
||||
expect(setFailedMock).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
'milliseconds not a number'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user