-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathconstructor_hex.js
48 lines (40 loc) · 1.6 KB
/
constructor_hex.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
var Chromath = require('..');
var test = require('tap').test;
var common = require('./common');
var util = require('../src/util');
test('constructor accepts hex arguments', function (t) {
util.times(100, common.generators.arbHex2Triplet).forEach(function (hexTriplet) {
var r = hexTriplet[0];
var g = hexTriplet[1];
var b = hexTriplet[2];
var hex6 = r + g + b;
// Hex (6 characters with hash)
t.doesNotThrow(function () {
var color = new Chromath('#' + hex6);
common.tests.isChromath(color, t);
common.tests.isLikeRGB(color, t);
}, '6 hex characters with a hash');
// Hex (6 characters without hash)
t.doesNotThrow(function () {
var color = new Chromath(hex6);
common.tests.isChromath(color, t);
common.tests.isLikeRGB(color, t);
}, '6 hex characters without a hash');
});
util.times(100, common.generators.arbHexTriplet).forEach(function (hexTriplet) {
var hex3 = hexTriplet.join('');
// Hex (3 characters with hash)
t.doesNotThrow(function () {
var color = new Chromath('#' + hex3);
common.tests.isChromath(color, t);
common.tests.isLikeRGB(color, t);
}, '3 hex characters with a hash');
// Hex (3 characters without hash)
t.doesNotThrow(function () {
var color = new Chromath(hex3);
common.tests.isChromath(color, t);
common.tests.isLikeRGB(color, t);
}, '3 hex characters without a hash');
});
t.end();
});