tauri.spec.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // eslint-disable-next-line node/no-missing-require
  2. const { tauri } = require('bin/tauri')
  3. describe('[CLI] tauri.js', () => {
  4. it('displays a help message', async () => {
  5. jest.spyOn(console, 'log')
  6. jest.spyOn(process, 'exit').mockImplementation(() => true)
  7. tauri('help')
  8. console.log(process.exit.mock.calls[0][0])
  9. expect(process.exit.mock.calls[0][0]).toBe(0)
  10. expect(!!console.log.mock.calls[0][0]).toBe(true)
  11. tauri('--help')
  12. expect(!!console.log.mock.calls[2][0]).toBe(true)
  13. tauri('-h')
  14. expect(!!console.log.mock.calls[3][0]).toBe(true)
  15. tauri(['help'])
  16. expect(!!console.log.mock.calls[4][0]).toBe(true)
  17. jest.clearAllMocks()
  18. })
  19. it('will not run an unavailable command', async () => {
  20. jest.spyOn(console, 'log')
  21. tauri('foo')
  22. expect(console.log.mock.calls[0][0].split('.')[0]).toBe('Invalid command foo')
  23. jest.clearAllMocks()
  24. })
  25. it('will pass on an available command', async () => {
  26. jest.spyOn(console, 'log')
  27. tauri('init')
  28. expect(console.log.mock.calls[0][0].split('.')[0]).toBe('[tauri]: running init')
  29. jest.clearAllMocks()
  30. })
  31. it('gets you help', async () => {
  32. jest.spyOn(console, 'log')
  33. tauri(['icon'])
  34. expect(!!console.log.mock.calls[0][0]).toBe(true)
  35. jest.clearAllMocks()
  36. })
  37. })