forked from dy/image-decode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
85 lines (61 loc) · 1.52 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
'use strict'
let decode = require('./')
let t = require('tape')
let fix = require('./fixture')
let fs = require('fs')
let eq = require('image-equal')
t('png', async t => {
let data = decode(fs.readFileSync('./fixture/test_pattern.png'))
t.ok(await eq(data, fix))
t.equal(data.width, fix.width)
t.equal(data.height, fix.height)
t.end()
})
t('jpg', async t => {
let data = decode(fs.readFileSync('./fixture/test_pattern.jpg'))
t.ok(await eq(data, fix, {tol: 0.04}))
t.equal(data.width, fix.width)
t.equal(data.height, fix.height)
t.end()
})
t('bmp', async t => {
let data = decode(fs.readFileSync('./fixture/test_pattern.jpg'))
t.ok(await eq(data, fix, {tol: 0.04}))
t.equal(data.width, fix.width)
t.equal(data.height, fix.height)
t.end()
})
t('gif', async t => {
let data = decode(fs.readFileSync('./fixture/test_pattern.gif'))
t.ok(await eq(data, fix))
t.equal(data.width, fix.width)
t.equal(data.height, fix.height)
t.end()
})
t.skip('webp', async t => {
let data = decode(fs.readFileSync('./fixture/test_pattern.webp'))
t.ok(await eq(data, fix))
t.equal(data.width, fix.width)
t.equal(data.height, fix.height)
t.end()
})
t('tiff', async t => {
let data = decode(fs.readFileSync('./fixture/test_pattern.tif'))
t.ok(await eq(data, fix))
t.equal(data.width, fix.width)
t.equal(data.height, fix.height)
t.end()
})
t('undefined type', async t => {
let data = decode([0,0,0,0,0,0,0,0,0])
t.notOk(data)
t.end()
})
// TODO
t('base64')
t('arraybuffer')
t('buffer')
t('uint8')
t('file')
t('blob')
t('datauri')