-
Notifications
You must be signed in to change notification settings - Fork 7
/
test.js
26 lines (21 loc) · 1.21 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
import assert from 'assert'
import rgba from './index.js'
assert.deepEqual(rgba('rgba(1,2,3,.5)'), [1, 2, 3, .5])
assert.deepEqual(rgba('rgba(0,0,0,0)'), [0, 0, 0, 0])
assert.deepEqual(rgba('hsla(0,0,0,1)'), [0, 0, 0, 1])
assert.deepEqual(rgba('rgba(-300,-300,-300,-1)'), [0, 0, 0, 0])
assert.deepEqual(rgba('red'), [255, 0, 0, 1])
assert.deepEqual(rgba('rgb(80, 120, 160)'), [80, 120, 160, 1])
assert.deepEqual(rgba('rgba(80, 120, 160, .5)'), [80, 120, 160, .5])
assert.deepEqual(rgba('rgba(80 120 160 / .5)'), [80, 120, 160, .5])
assert.deepEqual(rgba('hsl(291 80% 50%)'), [198.89999999999995, 25.499999999999993, 229.5, 1])
assert.deepEqual(rgba('hsl(0.8083333333333333turn 80% 50%)'), [198.89999999999995, 25.499999999999993, 229.5, 1])
assert.deepEqual(rgba('hsla(109, 50%, 50%, .75)'), [87.125, 191.25, 63.75, 0.75])
assert.deepEqual(rgba('#f00'), [255, 0, 0, 1])
assert.deepEqual(rgba`#f00`, [255, 0, 0, 1])
assert.deepEqual(rgba('xyz'), [])
// console.log(rgba('hsla(170, 50%, 45%, 1)'))
assert.deepEqual(rgba(0x00ff00), [0, 255, 0, 1])
assert.deepEqual(rgba(new Number(0x00ff00)), [0, 255, 0, 1])
assert.deepEqual(rgba([1, 1, 1, 1]), [1, 1, 1, 1])
assert.deepEqual(rgba(new Uint8Array([255, 255, 255, 255])), [255, 255, 255, 1])