forked from radiovisual/html-colors
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
35 lines (29 loc) · 753 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
import test from 'ava';
import colors from './html-colors';
import fn from './';
test('all', t => {
const all = fn.all();
t.is(typeof all, 'object');
t.is(all.black, '#000000');
t.is(Object.keys(colors).length, Object.keys(all).length);
});
test('names', t => {
const names = fn.names();
t.true(Array.isArray(names));
t.true(names.indexOf('black') > -1);
});
test('hex', t => {
const black = fn.hex('black');
t.is(black, '#000000');
t.throws(() => {
fn.hex();
}, 'htmlColors.hex expected a string, got undefined');
});
test('hex with uppercase characters', t => {
const yellow = fn.hex('YELLow');
t.is(yellow, '#FFFF00');
});
test('random', t => {
const random = fn.random();
t.true(Object.keys(colors).indexOf(random) > -1);
});