2020-03-10 03:27:54 +03:00
|
|
|
const appTestSetup = require('../fixtures/app-test-setup')
|
|
|
|
appTestSetup.initJest('app')
|
|
|
|
|
|
|
|
const tauricon = require('api/tauricon')
|
2019-11-18 00:30:14 +03:00
|
|
|
|
|
|
|
describe('[CLI] tauri-icon internals', () => {
|
|
|
|
it('tells you the version', () => {
|
|
|
|
const version = tauricon.version()
|
|
|
|
expect(!!version).toBe(true)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('will not validate a non-file', async () => {
|
2019-11-30 21:39:13 +03:00
|
|
|
jest.spyOn(process, 'exit').mockImplementation(() => true)
|
2020-08-19 05:36:46 +03:00
|
|
|
await tauricon.validate(
|
|
|
|
'test/jest/fixtures/doesnotexist.png',
|
|
|
|
'test/jest/fixtures/'
|
|
|
|
)
|
2019-11-30 21:39:13 +03:00
|
|
|
expect(process.exit.mock.calls[0][0]).toBe(1)
|
|
|
|
jest.clearAllMocks()
|
2019-11-18 00:30:14 +03:00
|
|
|
})
|
|
|
|
it('will not validate a non-png', async () => {
|
2019-11-30 21:39:13 +03:00
|
|
|
jest.spyOn(process, 'exit').mockImplementation(() => true)
|
2020-08-19 05:36:46 +03:00
|
|
|
await tauricon.validate(
|
|
|
|
'test/jest/fixtures/notAMeme.jpg',
|
|
|
|
'test/jest/fixtures/'
|
|
|
|
)
|
2019-11-30 21:39:13 +03:00
|
|
|
expect(process.exit.mock.calls[0][0]).toBe(1)
|
|
|
|
jest.clearAllMocks()
|
2019-11-18 00:30:14 +03:00
|
|
|
})
|
|
|
|
it('can validate an image as PNG', async () => {
|
2020-08-19 05:36:46 +03:00
|
|
|
const valid = await tauricon.validate(
|
|
|
|
'test/jest/fixtures/tauri-logo.png',
|
|
|
|
'test/jest/fixtures/'
|
|
|
|
)
|
2019-11-18 00:30:14 +03:00
|
|
|
expect(valid).toBe(true)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2019-11-30 21:39:13 +03:00
|
|
|
describe('[CLI] tauri-icon builder', () => {
|
|
|
|
it('will still use default compression if missing compression chosen', async () => {
|
2020-08-19 05:36:46 +03:00
|
|
|
const valid = await tauricon.make(
|
|
|
|
'test/jest/fixtures/tauri-logo.png',
|
|
|
|
'test/jest/tmp/missing',
|
|
|
|
'missing'
|
|
|
|
)
|
2019-11-30 21:39:13 +03:00
|
|
|
expect(valid).toBe(true)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('[CLI] tauri-icon builder', () => {
|
|
|
|
it('will not validate a non-file', async () => {
|
|
|
|
try {
|
2020-08-19 05:36:46 +03:00
|
|
|
await tauricon.make(
|
|
|
|
'test/jest/fixtures/tauri-foo-not-found.png',
|
|
|
|
'test/jest/tmp/pngquant',
|
|
|
|
'pngquant'
|
|
|
|
)
|
2019-11-30 21:39:13 +03:00
|
|
|
} catch (e) {
|
2019-12-27 14:06:55 +03:00
|
|
|
expect(e.message).toBe('Input file is missing')
|
2019-11-30 21:39:13 +03:00
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2019-11-18 00:30:14 +03:00
|
|
|
describe('[CLI] tauri-icon builder', () => {
|
|
|
|
it('makes a set of icons with pngquant', async () => {
|
2020-08-19 05:36:46 +03:00
|
|
|
const valid = await tauricon.make(
|
|
|
|
'test/jest/fixtures/tauri-logo.png',
|
|
|
|
'test/jest/tmp/pngquant',
|
|
|
|
'pngquant'
|
|
|
|
)
|
2019-11-18 00:30:14 +03:00
|
|
|
expect(valid).toBe(true)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('makes a set of icons with optipng', async () => {
|
2020-08-19 05:36:46 +03:00
|
|
|
const valid = await tauricon.make(
|
|
|
|
'test/jest/fixtures/tauri-logo.png',
|
|
|
|
'test/jest/tmp/optipng',
|
|
|
|
'optipng'
|
|
|
|
)
|
2019-11-18 00:30:14 +03:00
|
|
|
expect(valid).toBe(true)
|
|
|
|
})
|
|
|
|
|
2019-11-30 21:39:13 +03:00
|
|
|
/*
|
|
|
|
TURNED OFF BECAUSE IT TAKES FOREVER
|
2019-11-18 00:30:14 +03:00
|
|
|
it('makes a set of icons with zopfli', async () => {
|
2019-11-24 18:20:04 +03:00
|
|
|
jest.setTimeout(120000)
|
2019-11-18 00:30:14 +03:00
|
|
|
const valid = await tauricon.make('test/jest/fixtures/tauri-logo.png', 'test/jest/tmp/zopfli', 'zopfli')
|
|
|
|
expect(valid).toBe(true)
|
|
|
|
})
|
2019-11-30 21:39:13 +03:00
|
|
|
*/
|
2019-11-18 00:30:14 +03:00
|
|
|
})
|