-
Notifications
You must be signed in to change notification settings - Fork 3
/
utils.test.js
37 lines (35 loc) · 967 Bytes
/
utils.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
const { componentToHex, rgbToHex } = require("./utils");
describe("componentToHex", () => {
describe("Given 255", () => {
it("should return ff", () => {
expect(componentToHex(255)).toEqual("ff");
});
});
describe("Given 0", () => {
it("should return 00", () => {
expect(componentToHex(0)).toEqual("00");
});
});
describe("Given 169", () => {
it("should return a9", () => {
expect(componentToHex(169)).toEqual("a9");
});
});
});
describe("rgbToHex", () => {
describe("Given 245, 169, 184", () => {
it("should return #f5a9b8", () => {
expect(rgbToHex(245, 169, 184)).toEqual("#f5a9b8");
});
});
describe("Given 0, 0, 0", () => {
it("should return #000000", () => {
expect(rgbToHex(0, 0, 0)).toEqual("#000000");
});
});
describe("Given 255, 255, 255", () => {
it("should return #ffffff", () => {
expect(rgbToHex(255, 255, 255)).toEqual("#ffffff");
});
});
});