github-pages-deploy-action/__tests__/execute.test.ts

37 lines
844 B
TypeScript
Raw Normal View History

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', () => {
it('should be called with the correct arguments', async () => {
await stdout('hello')
await execute('echo Montezuma', './')
2020-03-05 21:19:45 +08:00
expect(exec).toBeCalledWith('echo Montezuma', [], {
cwd: './',
silent: true,
listeners: {
stdout: expect.any(Function)
}
2020-03-05 21:19:45 +08:00
})
})
2020-03-05 21:19:45 +08:00
it('should not silence the input when INPUT_DEBUG is defined', async () => {
process.env['DEBUG_DEPLOY_ACTION'] = 'yes'
2020-03-05 21:19:45 +08:00
await stdout('hello')
await execute('echo Montezuma', './')
2020-03-05 21:19:45 +08:00
expect(exec).toBeCalledWith('echo Montezuma', [], {
cwd: './',
silent: false,
listeners: {
stdout: expect.any(Function)
}
2020-03-05 21:19:45 +08:00
})
})
})