aboutsummaryrefslogtreecommitdiff
path: root/src/formats.test.ts
blob: fa22f0795a19f2ab75494ba1f73a4b12fc947a73 (plain) (blame)
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
import { defaultColorMatches } from "./formats";

describe("Color matcher", () => {
  it.each`
    n      | s1     | s2    | expected
    ${100} | ${75}  | ${50} | ${"0f0"}
    ${75}  | ${75}  | ${50} | ${"0f0"}
    ${50}  | ${75}  | ${50} | ${"ff0"}
    ${0}   | ${75}  | ${50} | ${"f00"}
    ${51}  | ${51}  | ${50} | ${"0f0"}
    ${50}  | ${51}  | ${50} | ${"ff0"}
    ${0}   | ${50}  | ${1}  | ${"f00"}
    ${100} | ${100} | ${0}  | ${"0f0"}
    ${0}   | ${100} | ${0}  | ${"ff0"}
    ${75}  | ${75}  | ${60} | ${"0f0"}
    ${74}  | ${75}  | ${60} | ${"1f0"}
    ${73}  | ${75}  | ${60} | ${"2f0"}
    ${72}  | ${75}  | ${60} | ${"3f0"}
    ${71}  | ${75}  | ${60} | ${"4f0"}
    ${70}  | ${75}  | ${60} | ${"5f0"}
    ${69}  | ${75}  | ${60} | ${"6f0"}
    ${68}  | ${75}  | ${60} | ${"7f0"}
    ${67}  | ${75}  | ${60} | ${"8f0"}
    ${66}  | ${75}  | ${60} | ${"9f0"}
    ${65}  | ${75}  | ${60} | ${"af0"}
    ${64}  | ${75}  | ${60} | ${"bf0"}
    ${63}  | ${75}  | ${60} | ${"cf0"}
    ${62}  | ${75}  | ${60} | ${"df0"}
    ${61}  | ${75}  | ${60} | ${"ef0"}
    ${60}  | ${75}  | ${60} | ${"ff0"}
    ${15}  | ${75}  | ${15} | ${"ff0"}
    ${14}  | ${75}  | ${15} | ${"fe0"}
    ${13}  | ${75}  | ${15} | ${"fd0"}
    ${12}  | ${75}  | ${15} | ${"fc0"}
    ${11}  | ${75}  | ${15} | ${"fb0"}
    ${10}  | ${75}  | ${15} | ${"fa0"}
    ${9}   | ${75}  | ${15} | ${"f90"}
    ${8}   | ${75}  | ${15} | ${"f80"}
    ${7}   | ${75}  | ${15} | ${"f70"}
    ${6}   | ${75}  | ${15} | ${"f60"}
    ${5}   | ${75}  | ${15} | ${"f50"}
    ${4}   | ${75}  | ${15} | ${"f40"}
    ${3}   | ${75}  | ${15} | ${"f30"}
    ${2}   | ${75}  | ${15} | ${"f20"}
    ${1}   | ${75}  | ${15} | ${"f10"}
    ${0}   | ${75}  | ${15} | ${"f00"}
  `("should return $expected at $n%", ({ n, s1, s2, expected }) => {
    // Arrange
    const gradient = { stage1: s1, stage2: s2 };

    // Act
    const result = defaultColorMatches(n, gradient);

    // Assert
    expect(result).toEqual(expected);
  });
});