tauricon.spec.js 2.2 KB

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