mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-19 16:41:34 +03:00
37afc5b0dc
* fix(tauri.js) determine app path correctly * fix(lint): replace backtick with single-quote * fix(tests) mock app-paths * fix(tauri.js) linting * fix(test) use local tauri on empty fixture * fix(tauri.js) linting * fix(workflows) use local tauri-bundler test-tauri-js-cli * fix(workflows) wrong cargo install command * fix(tauri) comment webview-spawning test Co-authored-by: nothingismagick <denjell@sfosc.org>
54 lines
1.6 KiB
JavaScript
54 lines
1.6 KiB
JavaScript
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')
|
|
jest.mock('fs')
|
|
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')
|
|
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()
|
|
}
|
|
})
|
|
})
|