tauri/cli/tauri.js/test/jest/__tests__/tauri.spec.js
nothingismagick 435ed1ab8f
chore/updates (#150)
* chore(deps:examples): update

* chore(update:tauri): serde_json
Closes #146
2019-12-10 20:10:45 +01:00

41 lines
1.3 KiB
JavaScript

// eslint-disable-next-line node/no-missing-require
const { tauri } = require('bin/tauri')
describe('[CLI] tauri.js', () => {
it('displays a help message', async () => {
jest.spyOn(console, 'log')
jest.spyOn(process, 'exit').mockImplementation(() => true)
tauri('help')
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)
tauri('--help')
expect(!!console.log.mock.calls[2][0]).toBe(true)
tauri('-h')
expect(!!console.log.mock.calls[3][0]).toBe(true)
tauri(['help'])
expect(!!console.log.mock.calls[4][0]).toBe(true)
jest.clearAllMocks()
})
it('will not run an unavailable command', async () => {
jest.spyOn(console, 'log')
tauri('foo')
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')
tauri('init')
expect(console.log.mock.calls[0][0].split('.')[0]).toBe('[tauri]: running init')
jest.clearAllMocks()
})
it('gets you help', async () => {
jest.spyOn(console, 'log')
tauri(['icon'])
expect(!!console.log.mock.calls[0][0]).toBe(true)
jest.clearAllMocks()
})
})