forked from external-repos/squoosh
Compare commits
1 Commits
surma/lol
...
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/*"
|
"/build/*"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rollup -c"
|
"build": "rollup -c",
|
||||||
|
"test": "uvu -r ts-node/register test"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "Google Chrome Developers <chromium-dev@google.com>",
|
"author": "Google Chrome Developers <chromium-dev@google.com>",
|
||||||
@@ -34,7 +35,9 @@
|
|||||||
"@types/node": "^15.6.1",
|
"@types/node": "^15.6.1",
|
||||||
"rollup": "^2.46.0",
|
"rollup": "^2.46.0",
|
||||||
"rollup-plugin-terser": "^7.0.2",
|
"rollup-plugin-terser": "^7.0.2",
|
||||||
|
"ts-node": "^10.2.1",
|
||||||
"typescript": "^4.1.3",
|
"typescript": "^4.1.3",
|
||||||
|
"uvu": "^0.5.1",
|
||||||
"which": "^2.0.2"
|
"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"],
|
"types": ["node"],
|
||||||
"allowJs": true
|
"allowJs": true
|
||||||
},
|
},
|
||||||
"include": ["src/**/*", "../codecs/**/*"]
|
"include": ["src/**/*", "../codecs/**/*"],
|
||||||
|
"ts-node": {
|
||||||
|
"transpileOnly": true,
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "commonjs"
|
||||||
|
},
|
||||||
|
"include": ["tests/**/*"]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user