Skip to content

Commit 33d7281

Browse files
committed
add test for pngInfo
1 parent 4662181 commit 33d7281

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

web_src/js/utils/image.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export function pngChunks(data) {
22
const view = new DataView(data.buffer, 0);
3-
if (view.getBigUint64(0) !== 9894494448401390090n) throw new Error(`Invalid png header`);
3+
if (view.getBigUint64(0) !== 9894494448401390090n) throw new Error('Invalid png header');
44

55
const decoder = new TextDecoder();
66
const chunks = [];

web_src/js/utils/image.test.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {pngChunks} from './image.js';
1+
import {pngChunks, pngInfo} from './image.js';
22

33
test('pngChunks', async () => {
44
const blob = await (await globalThis.fetch('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAADUlEQVQIHQECAP3/AAAAAgABzePRKwAAAABJRU5ErkJggg==')).blob();
@@ -8,3 +8,8 @@ test('pngChunks', async () => {
88
{name: 'IEND', data: new Uint8Array([])},
99
]);
1010
});
11+
12+
test('pngInfo', async () => {
13+
const blob = await (await globalThis.fetch('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAEElEQVQI12OQNZcAIgYIBQAL8gGxdzzM0A==')).blob();
14+
expect(await pngInfo(blob)).toEqual({dppx: 2, width: 2});
15+
});

0 commit comments

Comments
 (0)