2019-12-10 22:10:45 +03:00
|
|
|
// eslint-disable-next-line node/no-missing-require
|
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')
|
2019-11-16 21:51:46 +03:00
|
|
|
expect(console.log.mock.calls[0][0].split('.')[0]).toBe('Invalid command foo')
|
|
|
|
jest.clearAllMocks()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('will pass on an available command', async () => {
|
|
|
|
jest.spyOn(console, 'log')
|
2019-11-18 00:30:14 +03:00
|
|
|
tauri('init')
|
2019-11-16 21:51:46 +03:00
|
|
|
expect(console.log.mock.calls[0][0].split('.')[0]).toBe('[tauri]: running init')
|
|
|
|
jest.clearAllMocks()
|
|
|
|
})
|
2019-11-30 21:39:13 +03:00
|
|
|
it('gets you help', async () => {
|
|
|
|
jest.spyOn(console, 'log')
|
|
|
|
tauri(['icon'])
|
|
|
|
expect(!!console.log.mock.calls[0][0]).toBe(true)
|
|
|
|
jest.clearAllMocks()
|
|
|
|
})
|
2019-11-16 21:51:46 +03:00
|
|
|
})
|