Skip to content

Commit

Permalink
Increase mozjpeg test timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrilwanner committed Aug 5, 2020
1 parent 032e60d commit 05f518e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 31 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"scripts": {
"build": "lerna run build --parallel",
"lint": "lerna run lint --parallel",
"lint:fix": "lerna run lint:fix --parallel",
"test": "lerna run test --parallel",
"test:sizes": "lerna run test:sizes --parallel",
"postinstall": "lerna bootstrap",
Expand Down
60 changes: 30 additions & 30 deletions packages/gifsicle/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ describe('gifsicle', () => {
['tiny', 'small', 'medium', 'large'].forEach((size) => {
it(`encodes a ${size} image`, async () => {
jest.setTimeout(20000);
const data = getImageFile(`images/${size}.gif`);

const data = getImageFile(`images/${size}.gif`);
const originalSize = getFileSize(`images/${size}.gif`);
const originalMetadata = await getImageMetadata(`images/${size}.gif`);

Expand All @@ -41,64 +41,64 @@ describe('gifsicle', () => {
});
});

it('respects optimization level option', async () => {
const data = getImageFile('images/small.gif');
it('respects optimization level option', async () => {
const data = getImageFile('images/small.gif');

// with level 1
const resultLevel1 = await encode(data, { optimizationLevel: 1 });
const pathLevel1 = writeTmpBuffer(resultLevel1, 'small-level1.gif');
const sizeLevel1 = getFileSize(pathLevel1);
// with level 1
const resultLevel1 = await encode(data, { optimizationLevel: 1 });
const pathLevel1 = writeTmpBuffer(resultLevel1, 'small-level1.gif');
const sizeLevel1 = getFileSize(pathLevel1);

// with level 3
const resultLevel3 = await encode(data, { optimizationLevel: 3 });
const pathLevel3 = writeTmpBuffer(resultLevel3, 'small-level3.gif');
const sizeLevel3 = getFileSize(pathLevel3);
// with level 3
const resultLevel3 = await encode(data, { optimizationLevel: 3 });
const pathLevel3 = writeTmpBuffer(resultLevel3, 'small-level3.gif');
const sizeLevel3 = getFileSize(pathLevel3);

expect(sizeLevel1).toBeGreaterThan(sizeLevel3);
});

it('resizes correctly with both sides given', async () => {
const data = getImageFile('images/medium.gif');
const result = await encode(data, { width: 20, height: 30 });
it('resizes correctly with both sides given', async () => {
const data = getImageFile('images/medium.gif');
const result = await encode(data, { width: 20, height: 30 });
const encodedPath = writeTmpBuffer(result, 'medium-20x30.gif');

const metadata = await getImageMetadata(encodedPath);
const metadata = await getImageMetadata(encodedPath);
expect(metadata.format).toBe('gif');
expect(metadata.width).toBe(20);
expect(metadata.height).toBe(30);
});

it('resizes correctly with only width given', async () => {
const data = getImageFile('images/medium.gif');
const result = await encode(data, { width: 50 });
it('resizes correctly with only width given', async () => {
const data = getImageFile('images/medium.gif');
const result = await encode(data, { width: 50 });
const encodedPath = writeTmpBuffer(result, 'medium-50x_.gif');

const metadata = await getImageMetadata(encodedPath);
const metadata = await getImageMetadata(encodedPath);
expect(metadata.format).toBe('gif');
expect(metadata.width).toBe(50);
expect(metadata.height).toBe(28);
});

it('resizes correctly with only height given', async () => {
const data = getImageFile('images/medium.gif');
const result = await encode(data, { height: 25 });
it('resizes correctly with only height given', async () => {
const data = getImageFile('images/medium.gif');
const result = await encode(data, { height: 25 });
const encodedPath = writeTmpBuffer(result, 'medium-_x25.gif');

const metadata = await getImageMetadata(encodedPath);
const metadata = await getImageMetadata(encodedPath);
expect(metadata.format).toBe('gif');
expect(metadata.width).toBe(44);
expect(metadata.height).toBe(25);
});

it('respects colors option', async () => {
const data = getImageFile('images/small.gif');
const originalInfo = gifInfo(new Uint8Array(data).buffer);
it('respects colors option', async () => {
const data = getImageFile('images/small.gif');
const originalInfo = gifInfo(new Uint8Array(data).buffer);
expect(originalInfo.globalPaletteSize).toBe(256);
const result = await encode(data, { colors: 32 });

const result = await encode(data, { colors: 32 });
writeTmpBuffer(result, `small-32colors.gif`);

// check if new gif has only 32 colors
// check if new gif has only 32 colors
const encodeInfo = gifInfo(new Uint8Array(result).buffer);
expect(encodeInfo.globalPaletteSize).toBe(32);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/gifsicle/__tests__/performance.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { initTestUtils, getImageFile, getFileSize, getImageMetadata } from '@wasm-codecs/test-utils';
import { initTestUtils, getImageFile, getFileSize } from '@wasm-codecs/test-utils';
import encode from '../lib';

describe('gifsicle performance', () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/mozjpeg/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ describe('mozjpeg', () => {
// test all image sizes
['tiny', 'small', 'medium', 'large'].forEach((size) => {
it(`encodes a ${size} image`, async () => {
jest.setTimeout(20000);

const {
data,
info: { width, height, channels },
Expand Down

0 comments on commit 05f518e

Please sign in to comment.