tauricon.spec.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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(
  12. 'test/jest/fixtures/doesnotexist.png',
  13. 'test/jest/fixtures/'
  14. )
  15. expect(process.exit.mock.calls[0][0]).toBe(1)
  16. jest.clearAllMocks()
  17. })
  18. it('will not validate a non-png', async () => {
  19. jest.spyOn(process, 'exit').mockImplementation(() => true)
  20. await tauricon.validate(
  21. 'test/jest/fixtures/notAMeme.jpg',
  22. 'test/jest/fixtures/'
  23. )
  24. expect(process.exit.mock.calls[0][0]).toBe(1)
  25. jest.clearAllMocks()
  26. })
  27. it('should fail if PNG does not have transparency', async () => {
  28. jest.spyOn(process, 'exit').mockImplementation(() => true)
  29. await tauricon.validate(
  30. 'test/jest/fixtures/no-alpha.png',
  31. 'test/jest/fixtures/'
  32. )
  33. expect(process.exit.mock.calls[0][0]).toBe(1)
  34. jest.clearAllMocks()
  35. })
  36. it('can validate an image as PNG', async () => {
  37. const valid = await tauricon.validate(
  38. 'test/jest/fixtures/tauri-logo.png',
  39. 'test/jest/fixtures/'
  40. )
  41. expect(valid).toBe(true)
  42. })
  43. })
  44. describe('[CLI] tauri-icon builder', () => {
  45. it('will still use default compression if missing compression chosen', async () => {
  46. const valid = await tauricon.make(
  47. 'test/jest/fixtures/tauri-logo.png',
  48. 'test/jest/tmp/missing',
  49. 'missing'
  50. )
  51. expect(valid).toBe(true)
  52. })
  53. it('will not validate a non-file', async () => {
  54. try {
  55. await tauricon.make(
  56. 'test/jest/fixtures/tauri-foo-not-found.png',
  57. 'test/jest/tmp/optipng',
  58. 'optipng'
  59. )
  60. } catch (e) {
  61. expect(e.message).toBe('Input file is missing')
  62. }
  63. })
  64. it('makes a set of icons with optipng', async () => {
  65. const valid = await tauricon.make(
  66. 'test/jest/fixtures/tauri-logo.png',
  67. 'test/jest/tmp/optipng',
  68. 'optipng'
  69. )
  70. expect(valid).toBe(true)
  71. })
  72. /*
  73. TURNED OFF BECAUSE IT TAKES FOREVER
  74. it('makes a set of icons with zopfli', async () => {
  75. jest.setTimeout(120000)
  76. const valid = await tauricon.make('test/jest/fixtures/tauri-logo.png', 'test/jest/tmp/zopfli', 'zopfli')
  77. expect(valid).toBe(true)
  78. })
  79. */
  80. })