Compare commits
1 Commits
dependabot
...
libsquoosh
Author | SHA1 | Date | |
---|---|---|---|
4e04053e4c |
2248
libsquoosh/package-lock.json
generated
2248
libsquoosh/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,8 @@
|
||||
"/build/*"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "rollup -c"
|
||||
"build": "rollup -c",
|
||||
"test": "uvu -r ts-node/register test"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Google Chrome Developers <chromium-dev@google.com>",
|
||||
@ -34,7 +35,9 @@
|
||||
"@types/node": "^15.6.1",
|
||||
"rollup": "^2.46.0",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"ts-node": "^10.2.1",
|
||||
"typescript": "^4.1.3",
|
||||
"uvu": "^0.5.1",
|
||||
"which": "^2.0.2"
|
||||
}
|
||||
}
|
||||
|
43
libsquoosh/test/index.test.ts
Normal file
43
libsquoosh/test/index.test.ts
Normal file
@ -0,0 +1,43 @@
|
||||
import * as path from 'path';
|
||||
import { test } from 'uvu';
|
||||
import * as assert from 'uvu/assert';
|
||||
import { ImagePool } from '..';
|
||||
|
||||
let imagePool: ImagePool;
|
||||
|
||||
test.after.each(async () => {
|
||||
if (imagePool) {
|
||||
try {
|
||||
await imagePool.close();
|
||||
} catch (e) {}
|
||||
}
|
||||
imagePool = undefined;
|
||||
});
|
||||
|
||||
test('smoke test', async () => {
|
||||
imagePool = new ImagePool(1);
|
||||
|
||||
const imagePath = path.resolve(__dirname, '../../icon-large-maskable.png');
|
||||
const image = imagePool.ingestImage(imagePath);
|
||||
|
||||
const { bitmap } = await image.decoded;
|
||||
assert.equal(bitmap.width, 1024);
|
||||
|
||||
await image.preprocess({
|
||||
resize: {
|
||||
enabled: true,
|
||||
width: 100,
|
||||
},
|
||||
});
|
||||
|
||||
await image.encode({
|
||||
mozjpeg: {},
|
||||
});
|
||||
|
||||
const { size } = await image.encodedWith.mozjpeg;
|
||||
// resulting image is 1554b
|
||||
assert.ok(size > 500);
|
||||
assert.ok(size < 5000);
|
||||
});
|
||||
|
||||
test.run();
|
@ -5,5 +5,12 @@
|
||||
"types": ["node"],
|
||||
"allowJs": true
|
||||
},
|
||||
"include": ["src/**/*", "../codecs/**/*"]
|
||||
"include": ["src/**/*", "../codecs/**/*"],
|
||||
"ts-node": {
|
||||
"transpileOnly": true,
|
||||
"compilerOptions": {
|
||||
"module": "commonjs"
|
||||
},
|
||||
"include": ["tests/**/*"]
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user