-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.js
More file actions
21 lines (19 loc) · 717 Bytes
/
test.js
File metadata and controls
21 lines (19 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import {promises as fs} from 'node:fs';
// import isJpg from 'is-jpg';
// import isPng from 'is-png';
import test from 'ava';
import imageminAvif from './index.js';
// TODO: better testing
test('convert a JPG into AVIF', async t => {
const buffer = await fs.readFile(new URL('fixture.jpg', import.meta.url));
const data = await imageminAvif()(buffer);
// t.true(data.length < buffer.length);
// t.true(isJpg(data));
t.true(data.length > 0);
});
// test('throw error when a JPG is corrupt', async t => {
// const buffer = await fs.readFile(new URL('fixture-corrupt.jpg', import.meta.url));
// await t.throwsAsync(async () => {
// await imageminAvif()(buffer);
// }, {message: /Corrupt JPEG data/});
// });