2019-11-28 10:41:47 +03:00
|
|
|
const { tauri } = require('bin/tauri')
|
2019-11-16 21:51:46 +03:00
|
|
|
|
2021-04-12 07:59:25 +03:00
|
|
|
describe('[CLI] cli.js', () => {
|
2019-11-16 21:51:46 +03:00
|
|
|
it('displays a help message', async () => {
|
|
|
|
jest.spyOn(console, 'log')
|
|
|
|
jest.spyOn(process, 'exit').mockImplementation(() => true)
|
2019-11-18 00:30:14 +03:00
|
|
|
tauri('help')
|
2019-11-16 21:51:46 +03:00
|
|
|
console.log(process.exit.mock.calls[0][0])
|
|
|
|
expect(process.exit.mock.calls[0][0]).toBe(0)
|
|
|
|
expect(!!console.log.mock.calls[0][0]).toBe(true)
|
2019-11-18 00:30:14 +03:00
|
|
|
tauri('--help')
|
2019-11-16 21:51:46 +03:00
|
|
|
expect(!!console.log.mock.calls[2][0]).toBe(true)
|
2019-11-18 00:30:14 +03:00
|
|
|
tauri('-h')
|
2019-11-16 21:51:46 +03:00
|
|
|
expect(!!console.log.mock.calls[3][0]).toBe(true)
|
2019-11-18 00:30:14 +03:00
|
|
|
tauri(['help'])
|
|
|
|
expect(!!console.log.mock.calls[4][0]).toBe(true)
|
2019-11-16 21:51:46 +03:00
|
|
|
jest.clearAllMocks()
|
|
|
|
})
|
|
|
|
|
2019-11-30 21:39:13 +03:00
|
|
|
it('gets you help', async () => {
|
|
|
|
jest.spyOn(console, 'log')
|
2021-05-03 20:42:31 +03:00
|
|
|
const tests = ['--help', '-h']
|
2019-12-24 15:54:04 +03:00
|
|
|
for (const test of tests) {
|
|
|
|
tauri([test])
|
|
|
|
expect(!!console.log.mock.calls[0][0]).toBe(true)
|
|
|
|
jest.clearAllMocks()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
it('gets you version', async () => {
|
|
|
|
jest.spyOn(console, 'log')
|
|
|
|
const tests = ['--version', '-v']
|
|
|
|
const version = require('../../../package.json').version
|
|
|
|
for (const test of tests) {
|
|
|
|
tauri([test])
|
|
|
|
expect(console.log.mock.calls[0][0]).toBe(version)
|
|
|
|
jest.clearAllMocks()
|
|
|
|
}
|
2019-11-30 21:39:13 +03:00
|
|
|
})
|
2019-11-16 21:51:46 +03:00
|
|
|
})
|