2020-03-05 21:19:45 +08:00
|
|
|
import {execute, stdout} from '../src/execute'
|
|
|
|
import {exec} from '@actions/exec'
|
2020-01-12 09:26:08 +08:00
|
|
|
|
2020-03-05 21:19:45 +08:00
|
|
|
jest.mock('@actions/exec', () => ({
|
2020-01-12 09:26:08 +08:00
|
|
|
exec: jest.fn()
|
2020-03-05 21:19:45 +08:00
|
|
|
}))
|
2020-01-12 09:26:08 +08:00
|
|
|
|
2020-03-05 21:19:45 +08:00
|
|
|
describe('execute', () => {
|
2020-06-26 20:18:23 +08:00
|
|
|
it('should be called with the correct arguments when silent mode is enabled', async () => {
|
2020-03-28 22:35:26 +08:00
|
|
|
stdout('hello')
|
2020-06-26 20:18:23 +08:00
|
|
|
await execute('echo Montezuma', './', true)
|
2020-01-19 03:41:49 +08:00
|
|
|
|
2020-03-05 21:19:45 +08:00
|
|
|
expect(exec).toBeCalledWith('echo Montezuma', [], {
|
|
|
|
cwd: './',
|
2020-03-02 20:52:38 +08:00
|
|
|
silent: true,
|
|
|
|
listeners: {
|
|
|
|
stdout: expect.any(Function)
|
|
|
|
}
|
2020-03-05 21:19:45 +08:00
|
|
|
})
|
|
|
|
})
|
2020-03-02 20:52:38 +08:00
|
|
|
|
2020-06-26 20:18:23 +08:00
|
|
|
it('should not silence the input when action.silent is false', async () => {
|
2020-03-28 22:35:26 +08:00
|
|
|
process.env['RUNNER_DEBUG'] = '1'
|
2020-03-02 20:52:38 +08:00
|
|
|
|
2020-03-28 22:35:26 +08:00
|
|
|
stdout('hello')
|
2020-06-26 20:18:23 +08:00
|
|
|
await execute('echo Montezuma', './', false)
|
2020-03-02 20:52:38 +08:00
|
|
|
|
2020-03-05 21:19:45 +08:00
|
|
|
expect(exec).toBeCalledWith('echo Montezuma', [], {
|
|
|
|
cwd: './',
|
2020-03-02 20:52:38 +08:00
|
|
|
silent: false,
|
2020-01-19 03:41:49 +08:00
|
|
|
listeners: {
|
|
|
|
stdout: expect.any(Function)
|
|
|
|
}
|
2020-03-05 21:19:45 +08:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|