tauri.spec.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. const { tauri } = require('mode/bin/tauri')
  2. // const mockProcess = require('jest-mock-process')
  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. let result = tauri('help')
  8. console.log(process.exit.mock.calls[0][0])
  9. expect(process.exit.mock.calls[0][0]).toBe(0)
  10. // console.log(console.log.mock.calls[0][0])
  11. expect(!!console.log.mock.calls[0][0]).toBe(true)
  12. result = tauri('--help')
  13. // console.log(console.log.mock.calls[2][0])
  14. expect(!!console.log.mock.calls[2][0]).toBe(true)
  15. result = tauri('-h')
  16. expect(!!console.log.mock.calls[3][0]).toBe(true)
  17. jest.clearAllMocks()
  18. })
  19. it('will not run an unavailable command', async () => {
  20. jest.spyOn(console, 'log')
  21. let result = 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. let result = tauri('init')
  28. expect(console.log.mock.calls[0][0].split('.')[0]).toBe('[tauri]: running init')
  29. jest.clearAllMocks()
  30. })
  31. })