Skip to content

Commit 722884d

Browse files
committed
test: add self-tests for rgb to hsl conversion algorithm
1 parent b0929c8 commit 722884d

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { rgbToHsl } from '../RgbHslConversion'
2+
describe('RgbHslConversion', () => {
3+
const testCases = [
4+
[
5+
[215, 19, 180],
6+
[311, 84, 46]
7+
],
8+
[
9+
[21, 190, 18],
10+
[119, 83, 41]
11+
],
12+
[
13+
[80, 100, 160],
14+
[225, 33, 47]
15+
],
16+
[
17+
[80, 1, 16],
18+
[349, 98, 16]
19+
],
20+
[
21+
[8, 20, 0],
22+
[96, 100, 4]
23+
],
24+
[
25+
[0, 0, 0],
26+
[0, 0, 0]
27+
],
28+
[
29+
[255, 255, 255],
30+
[0, 0, 100]
31+
],
32+
[[256, 180, 9], 'Input is not a valid RGB color.'],
33+
[[-90, 46, 8], 'Input is not a valid RGB color.'],
34+
[[1, 39, 900], 'Input is not a valid RGB color.']
35+
]
36+
37+
test.each(testCases)(
38+
'Should return the color in HSL format.',
39+
(colorRgb, expected) => {
40+
expect(rgbToHsl(colorRgb)).toEqual(expected)
41+
}
42+
)
43+
})

0 commit comments

Comments
 (0)