-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
68 lines (57 loc) · 1.73 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
'use strict';
var assert = require('assert');
var colorDelta = require('./');
describe('colorDelta', function(){
it('should throw on invalid arguments', function() {
assert.throws(function() {
colorDelta();
}, /valid color/);
assert.throws(function() {
colorDelta('#bada55');
}, /valid color/);
});
it('should throw on invalid colors', function() {
assert.throws(function() {
colorDelta('#bada55a');
}, /valid color/);
assert.throws(function() {
colorDelta('#bada55', '#b0bca7a');
}, /valid color/);
});
it('should return object with diff', function() {
assert.deepEqual(colorDelta('#bada55', '#b0bca7'), {
hue: 19.849624060150404,
saturation: 0.5070282063269438,
lightness: -0.10196078431372546
});
assert.deepEqual(colorDelta('#ec008c', '#9f0962'), {
hue: -0.006779661016935279,
saturation: 0.1071428571428571,
lightness: 0.13333333333333336
});
});
it('should return object with diff to fixed decimals', function() {
assert.deepEqual(colorDelta('#bada55', '#b0bca7', 2), {
hue: 19.85,
saturation: 0.51,
lightness: -0.10
});
assert.deepEqual(colorDelta('#ec008c', '#9f0962', 2), {
hue: -0.01,
saturation: 0.11,
lightness: 0.13
});
});
it('should not do fixed decimals if passible a non-finite argument', function() {
assert.deepEqual(colorDelta('#bada55', '#b0bca7', false), {
hue: 19.849624060150404,
saturation: 0.5070282063269438,
lightness: -0.10196078431372546
});
assert.deepEqual(colorDelta('#ec008c', '#9f0962', -4), {
hue: -0.006779661016935279,
saturation: 0.1071428571428571,
lightness: 0.13333333333333336
});
});
});