tauri/cli/tauri.js/test/jest/__tests__/tauri.spec.js
Jacob Bolda 6a21965ff3
chore: add prettier for js formatting (#937)
* chore: add prettier for js/ts formatting

* fix lint-staged to object

* test commit

* format all

* lock file bump

* eslint extends prettier

This will let us skip rules in eslint that prettier can control. Prettier for styles, eslint for code errors.

* add prettier config

* roll back to what we had with eslint settings

* skip mutation observer

* add prettier typescript eslint

* run prettier in lint workflow

* format:check script

* turn off space before function in eslint

it is fighting with prettier

* fix dir in workflow

* remove semis

* add api to eslint

* shift eslint ignore comment after prettier format

* ignore errors that currently exist

* build:typevalidators

* replace was broken on typevalidator build

* try pushing up error

* format

* try removing working dir from eslint workflow

* try node 12

* fix indent in action

* bump eslint

* fix supposeded error and try another

* try breaking eslint

* try building in action

* adjust action paths again

* need dot

* remove build

* fix(tauri.js/eslint): escape glob *

* fix(tauri.js): ignore lint error

* Create prettier-taurijs.md

Co-authored-by: Noah Klayman <noahklayman@gmail.com>
2020-08-18 21:36:46 -05:00

60 lines
1.7 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')
try {
tauri('init')
} catch {}
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()
}
})
})