2019-11-28 10:41:47 +03:00
|
|
|
const { tauri } = require('bin/tauri')
|
2019-11-16 21:51:46 +03:00
|
|
|
|
|
|
|
describe('[CLI] tauri.js', () => {
|
|
|
|
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()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('will not run an unavailable command', async () => {
|
|
|
|
jest.spyOn(console, 'log')
|
2019-11-18 00:30:14 +03:00
|
|
|
tauri('foo')
|
2020-08-19 05:36:46 +03:00
|
|
|
expect(console.log.mock.calls[0][0].split('.')[0]).toBe(
|
|
|
|
'Invalid command foo'
|
|
|
|
)
|
2019-11-16 21:51:46 +03:00
|
|
|
jest.clearAllMocks()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('will pass on an available command', async () => {
|
|
|
|
jest.spyOn(console, 'log')
|
2020-03-07 19:40:24 +03:00
|
|
|
jest.mock('fs')
|
2020-07-10 17:41:31 +03:00
|
|
|
try {
|
2020-08-19 05:36:46 +03:00
|
|
|
tauri('init')
|
2020-07-10 17:41:31 +03:00
|
|
|
} catch {}
|
2020-08-19 05:36:46 +03:00
|
|
|
expect(console.log.mock.calls[0][0].split('.')[0]).toBe(
|
|
|
|
'[tauri]: running init'
|
|
|
|
)
|
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')
|
2019-12-24 15:54:04 +03:00
|
|
|
const tests = ['--help', '-h', 'invalid command']
|
|
|
|
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
|
|
|
})
|