|
1 | | -import assert from 'node:assert/strict'; |
2 | | -import Color from './../src/index.js'; |
3 | | - |
4 | | -describe('Color Attributes', function() { |
5 | | - |
6 | | - describe('#getAlpha', function() { |
7 | | - it('returns the alpha value', function() { |
8 | | - assert.strictEqual( |
9 | | - new Color(0, 0, 0, .75) |
10 | | - .getAlpha(), |
11 | | - .75 |
12 | | - ); |
13 | | - }); |
14 | | - }); |
15 | | - |
16 | | - describe('#getBrightness', function() { |
17 | | - it('returns the brightness value', function() { |
18 | | - assert.strictEqual( |
19 | | - Color.fromHSV(180, 50, 75) |
20 | | - .getBrightness(), |
21 | | - 75 |
22 | | - ); |
23 | | - }); |
24 | | - }); |
25 | | - |
26 | | - describe('#getHue', function() { |
27 | | - it('returns the hue value', function() { |
28 | | - assert.strictEqual( |
29 | | - Color.fromHSV(270, 50, 50) |
30 | | - .getHue(), |
31 | | - 270 |
32 | | - ); |
33 | | - }); |
34 | | - }); |
35 | | - |
36 | | - describe('#getSaturation', function() { |
37 | | - it('returns the saturation value', function() { |
38 | | - assert.strictEqual( |
39 | | - Color.fromHSV(180, 25, 50) |
40 | | - .getSaturation(), |
41 | | - 25 |
42 | | - ); |
43 | | - }); |
44 | | - }); |
45 | | - |
46 | | - describe('#luma', function() { |
47 | | - it('returns the relative luma value', function() { |
48 | | - assert.strictEqual( |
49 | | - Color.fromHSV(180, 50, 50) |
50 | | - .luma(), |
51 | | - .17935225036098287 |
52 | | - ); |
53 | | - }); |
54 | | - }); |
55 | | - |
56 | | - describe('#setAlpha', function() { |
57 | | - it('sets the alpha value', function() { |
58 | | - const color1 = Color.fromHSV(120, 50, 50); |
59 | | - const color2 = color1.setAlpha(.75); |
60 | | - assert.strictEqual( |
61 | | - color1.getAlpha(), |
62 | | - 1 |
63 | | - ); |
64 | | - assert.strictEqual( |
65 | | - color2.getAlpha(), |
66 | | - .75 |
67 | | - ); |
68 | | - }); |
69 | | - }); |
70 | | - |
71 | | - describe('#setBrightness', function() { |
72 | | - it('sets the brightness value', function() { |
73 | | - const color1 = Color.fromHSV(180, 50, 50); |
74 | | - const color2 = color1.setBrightness(75); |
75 | | - assert.strictEqual( |
76 | | - color1.getBrightness(), |
77 | | - 50 |
78 | | - ); |
79 | | - assert.strictEqual( |
80 | | - color2.getBrightness(), |
81 | | - 75 |
82 | | - ); |
83 | | - }); |
84 | | - }); |
85 | | - |
86 | | - describe('#setHue', function() { |
87 | | - it('sets the hue value', function() { |
88 | | - const color1 = Color.fromHSV(180, 50, 50); |
89 | | - const color2 = color1.setHue(270); |
90 | | - assert.strictEqual( |
91 | | - color1.getHue(), |
92 | | - 180 |
93 | | - ); |
94 | | - assert.strictEqual( |
95 | | - color2.getHue(), |
96 | | - 270 |
97 | | - ); |
98 | | - }); |
99 | | - }); |
100 | | - |
101 | | - describe('#setSaturation', function() { |
102 | | - it('sets the saturation value', function() { |
103 | | - const color1 = Color.fromHSV(180, 50, 50); |
104 | | - const color2 = color1.setSaturation(25); |
105 | | - assert.strictEqual( |
106 | | - color1.getSaturation(), |
107 | | - 50 |
108 | | - ); |
109 | | - assert.strictEqual( |
110 | | - color2.getSaturation(), |
111 | | - 25 |
112 | | - ); |
113 | | - }); |
114 | | - }); |
115 | | - |
116 | | -}); |
| 1 | +import assert from 'node:assert/strict'; |
| 2 | +import Color from './../src/index.js'; |
| 3 | + |
| 4 | +describe('Color Attributes', function() { |
| 5 | + describe('#getAlpha', function() { |
| 6 | + it('returns the alpha value', function() { |
| 7 | + assert.strictEqual( |
| 8 | + new Color(0, 0, 0, .75) |
| 9 | + .getAlpha(), |
| 10 | + .75, |
| 11 | + ); |
| 12 | + }); |
| 13 | + }); |
| 14 | + |
| 15 | + describe('#getBrightness', function() { |
| 16 | + it('returns the brightness value', function() { |
| 17 | + assert.strictEqual( |
| 18 | + Color.fromHSV(180, 50, 75) |
| 19 | + .getBrightness(), |
| 20 | + 75, |
| 21 | + ); |
| 22 | + }); |
| 23 | + }); |
| 24 | + |
| 25 | + describe('#getHue', function() { |
| 26 | + it('returns the hue value', function() { |
| 27 | + assert.strictEqual( |
| 28 | + Color.fromHSV(270, 50, 50) |
| 29 | + .getHue(), |
| 30 | + 270, |
| 31 | + ); |
| 32 | + }); |
| 33 | + }); |
| 34 | + |
| 35 | + describe('#getSaturation', function() { |
| 36 | + it('returns the saturation value', function() { |
| 37 | + assert.strictEqual( |
| 38 | + Color.fromHSV(180, 25, 50) |
| 39 | + .getSaturation(), |
| 40 | + 25, |
| 41 | + ); |
| 42 | + }); |
| 43 | + }); |
| 44 | + |
| 45 | + describe('#luma', function() { |
| 46 | + it('returns the relative luma value', function() { |
| 47 | + assert.strictEqual( |
| 48 | + Color.fromHSV(180, 50, 50) |
| 49 | + .luma(), |
| 50 | + .17935225036098287, |
| 51 | + ); |
| 52 | + }); |
| 53 | + }); |
| 54 | + |
| 55 | + describe('#setAlpha', function() { |
| 56 | + it('sets the alpha value', function() { |
| 57 | + const color1 = Color.fromHSV(120, 50, 50); |
| 58 | + const color2 = color1.setAlpha(.75); |
| 59 | + assert.strictEqual( |
| 60 | + color1.getAlpha(), |
| 61 | + 1, |
| 62 | + ); |
| 63 | + assert.strictEqual( |
| 64 | + color2.getAlpha(), |
| 65 | + .75, |
| 66 | + ); |
| 67 | + }); |
| 68 | + }); |
| 69 | + |
| 70 | + describe('#setBrightness', function() { |
| 71 | + it('sets the brightness value', function() { |
| 72 | + const color1 = Color.fromHSV(180, 50, 50); |
| 73 | + const color2 = color1.setBrightness(75); |
| 74 | + assert.strictEqual( |
| 75 | + color1.getBrightness(), |
| 76 | + 50, |
| 77 | + ); |
| 78 | + assert.strictEqual( |
| 79 | + color2.getBrightness(), |
| 80 | + 75, |
| 81 | + ); |
| 82 | + }); |
| 83 | + }); |
| 84 | + |
| 85 | + describe('#setHue', function() { |
| 86 | + it('sets the hue value', function() { |
| 87 | + const color1 = Color.fromHSV(180, 50, 50); |
| 88 | + const color2 = color1.setHue(270); |
| 89 | + assert.strictEqual( |
| 90 | + color1.getHue(), |
| 91 | + 180, |
| 92 | + ); |
| 93 | + assert.strictEqual( |
| 94 | + color2.getHue(), |
| 95 | + 270, |
| 96 | + ); |
| 97 | + }); |
| 98 | + }); |
| 99 | + |
| 100 | + describe('#setSaturation', function() { |
| 101 | + it('sets the saturation value', function() { |
| 102 | + const color1 = Color.fromHSV(180, 50, 50); |
| 103 | + const color2 = color1.setSaturation(25); |
| 104 | + assert.strictEqual( |
| 105 | + color1.getSaturation(), |
| 106 | + 50, |
| 107 | + ); |
| 108 | + assert.strictEqual( |
| 109 | + color2.getSaturation(), |
| 110 | + 25, |
| 111 | + ); |
| 112 | + }); |
| 113 | + }); |
| 114 | +}); |
0 commit comments