-
Notifications
You must be signed in to change notification settings - Fork 11
/
mix.test.ts
65 lines (55 loc) · 1.68 KB
/
mix.test.ts
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
58
59
60
61
62
63
64
65
import mix from './mix';
test('mix red with white', () => {
expect(mix('red', 'white', 0.5)).toMatchInlineSnapshot(
`"rgba(255, 128, 128, 1)"`
);
});
test('mix with red with black', () => {
expect(mix('red', 'black', 0.5)).toMatchInlineSnapshot(
`"rgba(128, 0, 0, 1)"`
);
});
test('mix red with blue', () => {
expect(mix('red', 'blue', 0.5)).toMatchInlineSnapshot(
`"rgba(128, 0, 128, 1)"`
);
});
test('weight 100%', () => {
expect(mix('red', 'blue', 1)).toMatchInlineSnapshot(`"rgba(0, 0, 255, 1)"`);
});
test('weight 0%', () => {
expect(mix('red', 'blue', 0)).toMatchInlineSnapshot(`"rgba(255, 0, 0, 1)"`);
});
test('mix with transparent', () => {
expect(mix('red', 'transparent', 0.5)).toMatchInlineSnapshot(
`"rgba(255, 0, 0, 0.5)"`
);
});
test('mix with transparent', () => {
expect(mix('rgba(255, 0, 0, 0)', 'blue', 0.5)).toMatchInlineSnapshot(
`"rgba(0, 0, 255, 0.5)"`
);
});
test('mix blue and green', () => {
expect(mix('blue', 'green', 0)).toMatchInlineSnapshot(`"rgba(0, 0, 255, 1)"`);
expect(mix('blue', 'green', 0.25)).toMatchInlineSnapshot(
`"rgba(0, 32, 191, 1)"`
);
expect(mix('blue', 'green', 0.5)).toMatchInlineSnapshot(
`"rgba(0, 64, 128, 1)"`
);
expect(mix('blue', 'green', 0.75)).toMatchInlineSnapshot(
`"rgba(0, 96, 64, 1)"`
);
expect(mix('blue', 'green', 1)).toMatchInlineSnapshot(`"rgba(0, 128, 0, 1)"`);
});
test('mix with transparent and weight 0%', () => {
expect(mix('transparent', 'blue', 0)).toMatchInlineSnapshot(
`"rgba(0, 0, 0, 0)"`
);
});
test('mix with transparent and weight 100%', () => {
expect(mix('red', 'rgba(255, 0, 0, 0)', 1)).toMatchInlineSnapshot(
`"rgba(255, 0, 0, 0)"`
);
});