/
_hslToRgb.test.js
43 lines (33 loc) · 1.41 KB
/
_hslToRgb.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
// @flow
import hslToRgb from '../_hslToRgb'
describe('hslToRgb', () => {
it('should convert numbers to a hex color', () => {
expect({ background: `rgb(${hslToRgb(360, 0.75, 0.4)})` }).toMatchSnapshot()
})
it('should convert the color red', () => {
expect({ background: `rgb(${hslToRgb(0, 1, 0.5)})` }).toMatchSnapshot()
})
it('should convert the color yellow', () => {
expect({ background: `rgb(${hslToRgb(60, 1, 0.5)})` }).toMatchSnapshot()
})
it('should convert the color lime', () => {
expect({ background: `rgb(${hslToRgb(120, 1, 0.5)})` }).toMatchSnapshot()
})
it('should convert the color cyan', () => {
expect({ background: `rgb(${hslToRgb(180, 1, 0.5)})` }).toMatchSnapshot()
})
it('should convert the color blue', () => {
expect({ background: `rgb(${hslToRgb(240, 1, 0.5)})` }).toMatchSnapshot()
})
it('should convert the color magenta', () => {
expect({ background: `rgb(${hslToRgb(300, 1, 0.5)})` }).toMatchSnapshot()
})
it('should convert black', () => {
expect({ background: `rgb(${hslToRgb(360, 0, 0.4)})` }).toMatchSnapshot()
})
it('should convert correctly even when passed a "faulty" negative hue', () => {
expect({ background: `rgb(${hslToRgb(-10, 1, 0.5)})` }).toMatchSnapshot()
expect({ background: `rgb(${hslToRgb(-100, 1, 0.5)})` }).toMatchSnapshot()
expect({ background: `rgb(${hslToRgb(-1000, 1, 0.5)})` }).toMatchSnapshot()
})
})