tauri/cli/tauri.js/test/jest/__tests__/tauricon.spec.js
Jacob Bolda 6a21965ff3
chore: add prettier for js formatting (#937)
* chore: add prettier for js/ts formatting

* fix lint-staged to object

* test commit

* format all

* lock file bump

* eslint extends prettier

This will let us skip rules in eslint that prettier can control. Prettier for styles, eslint for code errors.

* add prettier config

* roll back to what we had with eslint settings

* skip mutation observer

* add prettier typescript eslint

* run prettier in lint workflow

* format:check script

* turn off space before function in eslint

it is fighting with prettier

* fix dir in workflow

* remove semis

* add api to eslint

* shift eslint ignore comment after prettier format

* ignore errors that currently exist

* build:typevalidators

* replace was broken on typevalidator build

* try pushing up error

* format

* try removing working dir from eslint workflow

* try node 12

* fix indent in action

* bump eslint

* fix supposeded error and try another

* try breaking eslint

* try building in action

* adjust action paths again

* need dot

* remove build

* fix(tauri.js/eslint): escape glob *

* fix(tauri.js): ignore lint error

* Create prettier-taurijs.md

Co-authored-by: Noah Klayman <noahklayman@gmail.com>
2020-08-18 21:36:46 -05:00

92 lines
2.5 KiB
JavaScript

const appTestSetup = require('../fixtures/app-test-setup')
appTestSetup.initJest('app')
const tauricon = require('api/tauricon')
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 () => {
jest.spyOn(process, 'exit').mockImplementation(() => true)
await tauricon.validate(
'test/jest/fixtures/doesnotexist.png',
'test/jest/fixtures/'
)
expect(process.exit.mock.calls[0][0]).toBe(1)
jest.clearAllMocks()
})
it('will not validate a non-png', async () => {
jest.spyOn(process, 'exit').mockImplementation(() => true)
await tauricon.validate(
'test/jest/fixtures/notAMeme.jpg',
'test/jest/fixtures/'
)
expect(process.exit.mock.calls[0][0]).toBe(1)
jest.clearAllMocks()
})
it('can validate an image as PNG', async () => {
const valid = await tauricon.validate(
'test/jest/fixtures/tauri-logo.png',
'test/jest/fixtures/'
)
expect(valid).toBe(true)
})
})
describe('[CLI] tauri-icon builder', () => {
it('will still use default compression if missing compression chosen', async () => {
const valid = await tauricon.make(
'test/jest/fixtures/tauri-logo.png',
'test/jest/tmp/missing',
'missing'
)
expect(valid).toBe(true)
})
})
describe('[CLI] tauri-icon builder', () => {
it('will not validate a non-file', async () => {
try {
await tauricon.make(
'test/jest/fixtures/tauri-foo-not-found.png',
'test/jest/tmp/pngquant',
'pngquant'
)
} catch (e) {
expect(e.message).toBe('Input file is missing')
}
})
})
describe('[CLI] tauri-icon builder', () => {
it('makes a set of icons with pngquant', async () => {
const valid = await tauricon.make(
'test/jest/fixtures/tauri-logo.png',
'test/jest/tmp/pngquant',
'pngquant'
)
expect(valid).toBe(true)
})
it('makes a set of icons with optipng', async () => {
const valid = await tauricon.make(
'test/jest/fixtures/tauri-logo.png',
'test/jest/tmp/optipng',
'optipng'
)
expect(valid).toBe(true)
})
/*
TURNED OFF BECAUSE IT TAKES FOREVER
it('makes a set of icons with zopfli', async () => {
jest.setTimeout(120000)
const valid = await tauricon.make('test/jest/fixtures/tauri-logo.png', 'test/jest/tmp/zopfli', 'zopfli')
expect(valid).toBe(true)
})
*/
})