-
Notifications
You must be signed in to change notification settings - Fork 471
/
Copy pathtests.ts
78 lines (75 loc) · 1.57 KB
/
tests.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
66
67
68
69
70
71
72
73
74
75
76
77
78
export type TestValue = string | Record<string, string>;
export type TestStep =
| {
command: "merge" | "set";
key: string;
value: TestValue;
expected?: TestValue | null;
}
| {
command: "remove";
key: string;
};
const tests: Record<string, TestStep[]> = {
"Should store value": [
{ command: "set", key: "a", value: "0" },
{ command: "set", key: "a", value: "10" },
{ command: "set", key: "a", value: "20" },
{ command: "set", key: "a", value: "30" },
{ command: "set", key: "a", value: "40" },
],
"Should clear item": [
{ command: "set", key: "a", value: "42" },
{ command: "remove", key: "a" },
],
"Should merge items": [
{
command: "set",
key: "a",
value: {
name: "Jerry",
age: "21",
shoeSize: "10",
},
},
{
command: "merge",
key: "a",
value: {
name: "Sarah",
age: "23",
eyesColor: "green",
},
expected: {
name: "Sarah",
age: "23",
eyesColor: "green",
shoeSize: "10",
},
},
],
"Should keep existing entries when merging with an empty object": [
{
command: "set",
key: "merge_test_2",
value: {
name: "Jerry",
age: "21",
eyesColor: "blue",
shoeSize: "9",
},
},
{
command: "merge",
key: "merge_test_2",
value: {},
expected: {
name: "Jerry",
age: "21",
eyesColor: "blue",
shoeSize: "9",
},
},
],
};
export default tests;