This repository has been archived by the owner on Nov 6, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathExt.js
275 lines (208 loc) · 6 KB
/
Ext.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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
import Mint from "./Main.js";
const REACT_ELEMENT = Symbol.for("react.element");
test("comparing react elements", () => {
expect(
Mint.compare({ $$typeof: REACT_ELEMENT }, { $$typeof: REACT_ELEMENT })
).toBe(false);
expect(Mint.compare(null, { $$typeof: REACT_ELEMENT })).toBe(false);
});
test("comparing nodes", () => {
expect(Mint.compare(document.body, document.body)).toBe(true);
expect(Mint.compare(document.body, document.head)).toBe(false);
});
test("comparing same symbols", () => {
expect(Mint.compare(Symbol("A"), Symbol("A"))).toBe(false);
});
test("comparing same arrays", () => {
expect(["A"] == ["A"]).toBe(false);
expect(Mint.compare(["A"], ["A"])).toBe(true);
});
test("comparing functions", () => {
expect(
Mint.compare(
() => {},
() => {}
)
).toBe(false);
});
test("comparing empty arrays", () => {
expect([] == []).toBe(false);
expect(Mint.compare([], [])).toBe(true);
});
test("comparing arrays with null", () => {
expect(Mint.compare([], null)).toBe(false);
});
test("comparing arrays with undefined", () => {
expect(Mint.compare([], undefined)).toBe(false);
});
test("comparing different length arrays", () => {
expect(["A"] == ["A"]).toBe(false);
expect(Mint.compare(["A", "B"], ["A"])).toBe(false);
});
test("comparing different arrays", () => {
expect(Mint.compare(["A"], ["B"])).toBe(false);
});
test("comparing same dates", () => {
expect(new Date() == new Date()).toBe(false);
expect(Mint.compare(new Date(), new Date())).toBe(true);
});
test("comparing different dates", () => {
expect(Mint.compare(new Date(2018, 1, 1), new Date(2018, 1, 2))).toBe(false);
});
test("comparing same strings", () => {
expect(Mint.compare("A", "A")).toBe(true);
});
test("comparing same numbers", () => {
expect(Mint.compare(0, 0.0)).toBe(true);
});
test("comparing booleans", () => {
expect(Mint.compare(true, true)).toBe(true);
});
describe("URLSearchParams", () => {
test("false for null", () => {
const a = new URLSearchParams("a=b&c=d");
expect(Mint.compare(a, null)).toBe(false);
});
test("false for undefined", () => {
const a = new URLSearchParams("a=b&c=d");
expect(Mint.compare(a, undefined)).toBe(false);
});
test("same data are equal", () => {
const a = new URLSearchParams("a=b&c=d");
const b = new URLSearchParams("a=b&c=d");
expect(Mint.compare(a, b)).toBe(true);
});
});
describe("Map", () => {
test("false for undefined", () => {
const a = new Map();
expect(Mint.compare(a, undefined)).toBe(false);
});
test("false for null", () => {
const a = new Map();
expect(Mint.compare(a, null)).toBe(false);
});
test("same data are equal", () => {
const a = new Map([
["A", "B"],
["X", "Y"],
]);
const b = new Map([
["A", "B"],
["X", "Y"],
]);
expect(Mint.compare(a, b)).toBe(true);
});
test("same data with different order are equal", () => {
const a = new Map([
["X", "Y"],
["A", "B"],
]);
const b = new Map([
["A", "B"],
["X", "Y"],
]);
expect(Mint.compare(a, b)).toBe(true);
});
test("empty maps are equal", () => {
const a = new Map();
const b = new Map();
expect(Mint.compare(a, b)).toBe(true);
});
test("different data are not equal", () => {
const a = new Map([
["A", "B"],
["X", "Z"],
]);
const b = new Map([
["A", "B"],
["X", "Y"],
]);
expect(Mint.compare(a, b)).toBe(false);
});
test("data with different number of keys are not equal", () => {
const a = new Map([["A", "B"]]);
const b = new Map([
["A", "B"],
["X", "Y"],
]);
expect(Mint.compare(a, b)).toBe(false);
});
});
describe("Set", () => {
test("false for undefined", () => {
const a = new Set([]);
expect(Mint.compare(a, undefined)).toBe(false);
});
test("false for null", () => {
const a = new Set([]);
expect(Mint.compare(a, null)).toBe(false);
});
test("same data are equal", () => {
const a = new Set(["A", "B", "B"]);
const b = new Set(["A", "B", "B"]);
expect(Mint.compare(a, b)).toBe(true);
});
test("same data not in order are equal", () => {
const a = new Set(["B", "A", "A"]);
const b = new Set(["A", "B", "B"]);
expect(Mint.compare(a, b)).toBe(true);
});
test("different data does not equal", () => {
const a = new Set(["B", "C", "A"]);
const b = new Set(["A", "B", "B"]);
expect(Mint.compare(a, b)).toBe(false);
});
});
describe("FormData", () => {
test("false for undefined", () => {
const a = new FormData();
expect(Mint.compare(a, undefined)).toBe(false);
});
test("false for null", () => {
const a = new FormData();
expect(Mint.compare(a, null)).toBe(false);
});
test("empty form datas are equal", () => {
expect(Mint.compare(new FormData(), new FormData())).toBe(true);
});
test("same data form datas are equal", () => {
const a = new FormData();
a.append("a", "a");
const b = new FormData();
b.append("a", "a");
expect(Mint.compare(a, b)).toBe(true);
});
test("different datas are not equal", () => {
const a = new FormData();
a.append("a", "a");
const b = new FormData();
b.append("b", "a");
expect(Mint.compare(a, b)).toBe(false);
});
test("different datas are not equal", () => {
const a = new FormData();
a.append("a", "b");
const b = new FormData();
b.append("a", "a");
expect(Mint.compare(a, b)).toBe(false);
});
test("same multiple data form datas are equal", () => {
const a = new FormData();
a.append("a", "a");
a.append("a", "b");
const b = new FormData();
b.append("a", "b");
b.append("a", "a");
expect(Mint.compare(a, b)).toBe(true);
});
test("same multiple data form datas with different order are equal", () => {
const a = new FormData();
a.append("a", "b");
a.append("x", "y");
const b = new FormData();
b.append("x", "y");
b.append("a", "b");
expect(Mint.compare(a, b)).toBe(true);
});
});