-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtest.js
38 lines (32 loc) · 841 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const test = require('tape')
const path = require('path')
const Chunks = require('./')
const fs = require('fs')
test('png-chunks-extract', function (t) {
const data = fs.readFileSync(path.join(__dirname, 'test.png'))
t.deepEqual(
Chunks(data),
Chunks(new Uint8Array(data)),
'works identically with buffers and Uint8Arrays'
)
const chunks = Chunks(data)
const names = chunks.map(function (chunk) {
return chunk.name
})
const lengths = chunks.map(function (chunk) {
return chunk.data.length
})
t.deepEqual(lengths, [ 13, 3094, 9, 413, 16384, 16384, 16384, 7168, 0 ], 'extracted chunk lengths are as expected')
t.deepEqual(names, [
'IHDR',
'iCCP',
'pHYs',
'iTXt',
'IDAT',
'IDAT',
'IDAT',
'IDAT',
'IEND'
], 'extracted chunk names are as expected')
t.end()
})