tauri.spec.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. const { tauri } = require('bin/tauri')
  2. describe('[CLI] cli.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('gets you help', async () => {
  19. jest.spyOn(console, 'log')
  20. const tests = ['--help', '-h']
  21. for (const test of tests) {
  22. tauri([test])
  23. expect(!!console.log.mock.calls[0][0]).toBe(true)
  24. jest.clearAllMocks()
  25. }
  26. })
  27. it('gets you version', async () => {
  28. jest.spyOn(console, 'log')
  29. const tests = ['--version', '-v']
  30. const version = require('../../../package.json').version
  31. for (const test of tests) {
  32. tauri([test])
  33. expect(console.log.mock.calls[0][0]).toBe(version)
  34. jest.clearAllMocks()
  35. }
  36. })
  37. })