tauri.spec.js 1.1 KB

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