tauricon.spec.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. const { tauricon } = require('mode/helpers/tauricon')
  2. const { tauri } = require('mode/bin/tauri')
  3. describe('[CLI] tauri-icon internals', () => {
  4. it('tells you the version', () => {
  5. const version = tauricon.version()
  6. expect(!!version).toBe(true)
  7. })
  8. it('gets you help', async () => {
  9. jest.spyOn(console, 'log')
  10. tauri(['icon', 'help'])
  11. expect(!!console.log.mock.calls[0][0]).toBe(true)
  12. jest.clearAllMocks()
  13. })
  14. it('will not validate a non-file', async () => {
  15. try {
  16. await tauricon.validate('test/jest/fixtures/doesnotexist.png', 'test/jest/fixtures/')
  17. } catch (e) {
  18. expect(e.message).toBe('[ERROR] Source image for tauricon not found')
  19. }
  20. })
  21. it('will not validate a non-png', async () => {
  22. try {
  23. await tauricon.validate('test/jest/fixtures/notAMeme.jpg', 'test/jest/fixtures/')
  24. } catch (e) {
  25. expect(e.message).toBe('[ERROR] Source image for tauricon is not a png')
  26. }
  27. })
  28. it('can validate an image as PNG', async () => {
  29. const valid = await tauricon.validate('test/jest/fixtures/tauri-logo.png', 'test/jest/fixtures/')
  30. expect(valid).toBe(true)
  31. })
  32. })
  33. /**
  34. * This test suite takes A LOT of time. Maybe 5 minutes...? You may blame
  35. * Zopfli, but don't blame us for trying to help you get the smallest
  36. * possible binaries!
  37. */
  38. describe('[CLI] tauri-icon builder', () => {
  39. it('makes a set of icons with pngquant', async () => {
  40. const valid = await tauricon.make('test/jest/fixtures/tauri-logo.png', 'test/jest/tmp/pngquant', 'pngquant')
  41. expect(valid).toBe(true)
  42. })
  43. it('makes a set of icons with optipng', async () => {
  44. const valid = await tauricon.make('test/jest/fixtures/tauri-logo.png', 'test/jest/tmp/optipng', 'optipng')
  45. expect(valid).toBe(true)
  46. })
  47. it('makes a set of icons with zopfli', async () => {
  48. const valid = await tauricon.make('test/jest/fixtures/tauri-logo.png', 'test/jest/tmp/zopfli', 'zopfli')
  49. expect(valid).toBe(true)
  50. })
  51. })