tauricon.spec.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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('can validate an image as PNG', async () => {
  28. const valid = await tauricon.validate(
  29. 'test/jest/fixtures/tauri-logo.png',
  30. 'test/jest/fixtures/'
  31. )
  32. expect(valid).toBe(true)
  33. })
  34. })
  35. describe('[CLI] tauri-icon builder', () => {
  36. it('will still use default compression if missing compression chosen', async () => {
  37. const valid = await tauricon.make(
  38. 'test/jest/fixtures/tauri-logo.png',
  39. 'test/jest/tmp/missing',
  40. 'missing'
  41. )
  42. expect(valid).toBe(true)
  43. })
  44. })
  45. describe('[CLI] tauri-icon builder', () => {
  46. it('will not validate a non-file', async () => {
  47. try {
  48. await tauricon.make(
  49. 'test/jest/fixtures/tauri-foo-not-found.png',
  50. 'test/jest/tmp/pngquant',
  51. 'pngquant'
  52. )
  53. } catch (e) {
  54. expect(e.message).toBe('Input file is missing')
  55. }
  56. })
  57. })
  58. describe('[CLI] tauri-icon builder', () => {
  59. it('makes a set of icons with pngquant', async () => {
  60. const valid = await tauricon.make(
  61. 'test/jest/fixtures/tauri-logo.png',
  62. 'test/jest/tmp/pngquant',
  63. 'pngquant'
  64. )
  65. expect(valid).toBe(true)
  66. })
  67. it('makes a set of icons with optipng', async () => {
  68. const valid = await tauricon.make(
  69. 'test/jest/fixtures/tauri-logo.png',
  70. 'test/jest/tmp/optipng',
  71. 'optipng'
  72. )
  73. expect(valid).toBe(true)
  74. })
  75. /*
  76. TURNED OFF BECAUSE IT TAKES FOREVER
  77. it('makes a set of icons with zopfli', async () => {
  78. jest.setTimeout(120000)
  79. const valid = await tauricon.make('test/jest/fixtures/tauri-logo.png', 'test/jest/tmp/zopfli', 'zopfli')
  80. expect(valid).toBe(true)
  81. })
  82. */
  83. })