-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
47 lines (44 loc) · 1.04 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
const test = require('tape')
var Pixels
var toPixels
test('module is require-able', function (t) {
Pixels = require('./')
t.equal(typeof Pixels, 'function')
t.end()
})
test('create white pixel', function (t) {
const pixels = Pixels({
data: [0xff, 0xff, 0xff],
format: 'rgb'
})
t.equal(typeof pixels, 'object')
t.deepEqual(pixels.shape, [3])
t.deepEqual(pixels.data, [0xff, 0xff, 0xff])
t.equal(pixels.format, 'rgb')
t.ok(Pixels.is(pixels))
t.end()
})
test('create pixels', function (t) {
const pixels = Pixels({
data: [
0xff, 0x00, 0x84,
0x84, 0xff, 0x00,
0x00, 0x84, 0xff
],
shape: [3, 3],
format: 'rgb'
})
t.equal(typeof pixels, 'object')
t.deepEqual(pixels.shape, [3, 3])
t.equal(pixels.format, 'rgb')
t.ok(Pixels.is(pixels))
t.equal(pixels.get(0, 0), 0xff)
t.equal(pixels.get(0, 1), 0x00)
t.equal(pixels.get(0, 2), 0x84)
const pixel = pixels.pick(2)
t.equal(pixel.get(0), 0x00)
t.equal(pixel.get(1), 0x84)
t.equal(pixel.get(2), 0xff)
t.ok(Pixels.is(pixel))
t.end()
})