tauricon.spec.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. const appTestSetup = require('../fixtures/app-test-setup')
  2. appTestSetup.initJest('app')
  3. const tauricon = require('api/tauricon')
  4. describe('[CLI] tauri-icon internals', () => {
  5. it('tells you the version', () => {
  6. const version = tauricon.version()
  7. expect(!!version).toBe(true)
  8. })
  9. it('will not validate a non-file', async () => {
  10. jest.spyOn(process, 'exit').mockImplementation(() => true)
  11. await tauricon.validate('test/jest/fixtures/doesnotexist.png', 'test/jest/fixtures/')
  12. expect(process.exit.mock.calls[0][0]).toBe(1)
  13. jest.clearAllMocks()
  14. })
  15. it('will not validate a non-png', async () => {
  16. jest.spyOn(process, 'exit').mockImplementation(() => true)
  17. await tauricon.validate('test/jest/fixtures/notAMeme.jpg', 'test/jest/fixtures/')
  18. expect(process.exit.mock.calls[0][0]).toBe(1)
  19. jest.clearAllMocks()
  20. })
  21. it('can validate an image as PNG', async () => {
  22. const valid = await tauricon.validate('test/jest/fixtures/tauri-logo.png', 'test/jest/fixtures/')
  23. expect(valid).toBe(true)
  24. })
  25. })
  26. describe('[CLI] tauri-icon builder', () => {
  27. it('will still use default compression if missing compression chosen', async () => {
  28. const valid = await tauricon.make('test/jest/fixtures/tauri-logo.png', 'test/jest/tmp/missing', 'missing')
  29. expect(valid).toBe(true)
  30. })
  31. })
  32. describe('[CLI] tauri-icon builder', () => {
  33. it('will not validate a non-file', async () => {
  34. try {
  35. await tauricon.make('test/jest/fixtures/tauri-foo-not-found.png', 'test/jest/tmp/pngquant', 'pngquant')
  36. } catch (e) {
  37. expect(e.message).toBe('Input file is missing')
  38. }
  39. })
  40. })
  41. describe('[CLI] tauri-icon builder', () => {
  42. it('makes a set of icons with pngquant', async () => {
  43. const valid = await tauricon.make('test/jest/fixtures/tauri-logo.png', 'test/jest/tmp/pngquant', 'pngquant')
  44. expect(valid).toBe(true)
  45. })
  46. it('makes a set of icons with optipng', async () => {
  47. const valid = await tauricon.make('test/jest/fixtures/tauri-logo.png', 'test/jest/tmp/optipng', 'optipng')
  48. expect(valid).toBe(true)
  49. })
  50. /*
  51. TURNED OFF BECAUSE IT TAKES FOREVER
  52. it('makes a set of icons with zopfli', async () => {
  53. jest.setTimeout(120000)
  54. const valid = await tauricon.make('test/jest/fixtures/tauri-logo.png', 'test/jest/tmp/zopfli', 'zopfli')
  55. expect(valid).toBe(true)
  56. })
  57. */
  58. })