@gasboost/client 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +386 -0
- package/dist/navigation/AppsScriptIframe.js +5 -4
- package/package.json +21 -1
- package/dist/AppsScriptJob.d.ts +0 -28
- package/dist/AppsScriptJob.js +0 -84
- package/dist/AppsScriptJobQueue.d.ts +0 -14
- package/dist/AppsScriptJobQueue.js +0 -40
- package/dist/AppsScriptJobRunner.d.ts +0 -20
- package/dist/AppsScriptJobRunner.js +0 -93
- package/dist/AppsScriptJobStore.d.ts +0 -7
- package/dist/AppsScriptJobStore.js +0 -9
- package/src/AppsScriptClient.ts +0 -81
- package/src/google.ts +0 -55
- package/src/index.ts +0 -4
- package/src/job/AppsScriptJob.ts +0 -85
- package/src/job/AppsScriptJobQueue.ts +0 -48
- package/src/job/AppsScriptJobRunner.ts +0 -107
- package/src/job/AppsScriptJobStore.ts +0 -16
- package/src/navigation/AppsScriptContainer.ts +0 -47
- package/src/navigation/AppsScriptHistoryPipeline.ts +0 -29
- package/src/navigation/AppsScriptIframe.ts +0 -63
- package/src/navigation/HashProperty.ts +0 -20
- package/src/navigation/NavigationEntry.ts +0 -82
- package/src/navigation/NavigationLocation.ts +0 -54
- package/tests/AppsScriptClient.spec.ts +0 -322
- package/tests/AppsScriptClient.type.spec.ts +0 -52
- package/tests/AppsScriptContainer.spec.ts +0 -502
- package/tests/AppsScriptHistoryPipeline.spec.ts +0 -303
- package/tests/AppsScriptIframe.spec.ts +0 -452
- package/tests/AppsScriptJob.spec.ts +0 -83
- package/tests/AppsScriptJobQueue.spec.ts +0 -125
- package/tests/AppsScriptJobRunner.spec.ts +0 -361
- package/tests/HashProperty.spec.ts +0 -29
- package/tests/NavigationEntry.spec.ts +0 -507
- package/tests/NavigationLocation.spec.ts +0 -189
- package/tests/setup.ts +0 -15
- package/tsconfig.build.json +0 -14
- package/tsconfig.json +0 -6
- package/vitest.config.mts +0 -8
|
@@ -1,507 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
GoogleScriptHistoryEvent,
|
|
5
|
-
GoogleScriptUrlLocation,
|
|
6
|
-
} from "../src/google";
|
|
7
|
-
import { HashProperty } from "../src/navigation/HashProperty";
|
|
8
|
-
import { NavigationEntry } from "../src/navigation/NavigationEntry";
|
|
9
|
-
import { NavigationLocation } from "../src/navigation/NavigationLocation";
|
|
10
|
-
|
|
11
|
-
describe("NavigationEntry", () => {
|
|
12
|
-
describe("fromGoogle", () => {
|
|
13
|
-
it("GoogleScriptUrlLocation から NavigationEntry を生成できる", () => {
|
|
14
|
-
const source: GoogleScriptUrlLocation = {
|
|
15
|
-
hash: "/users",
|
|
16
|
-
parameter: {
|
|
17
|
-
page: "1",
|
|
18
|
-
},
|
|
19
|
-
parameters: {
|
|
20
|
-
page: ["1"],
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const entry = NavigationEntry.fromGoogle(source);
|
|
25
|
-
|
|
26
|
-
expect(entry.state).toEqual({});
|
|
27
|
-
expect(entry.location.hash.normalize()).toBe("#/users");
|
|
28
|
-
expect(entry.location.searchParams.get("page")).toBe("1");
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("GoogleScriptUrlLocation から生成した場合は state が空オブジェクトになる", () => {
|
|
32
|
-
const source: GoogleScriptUrlLocation = {
|
|
33
|
-
hash: "/users",
|
|
34
|
-
parameter: {},
|
|
35
|
-
parameters: {},
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const entry = NavigationEntry.fromGoogle(source);
|
|
39
|
-
|
|
40
|
-
expect(entry.state).toEqual({});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("GoogleScriptHistoryEvent から NavigationEntry を生成できる", () => {
|
|
44
|
-
const source: GoogleScriptHistoryEvent = {
|
|
45
|
-
state: {
|
|
46
|
-
selectedUserId: "123",
|
|
47
|
-
},
|
|
48
|
-
location: {
|
|
49
|
-
hash: "/users",
|
|
50
|
-
parameter: {
|
|
51
|
-
page: "1",
|
|
52
|
-
},
|
|
53
|
-
parameters: {
|
|
54
|
-
page: ["1"],
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const entry = NavigationEntry.fromGoogle(source);
|
|
60
|
-
|
|
61
|
-
expect(entry.state).toEqual({
|
|
62
|
-
selectedUserId: "123",
|
|
63
|
-
});
|
|
64
|
-
expect(entry.location.hash.normalize()).toBe("#/users");
|
|
65
|
-
expect(entry.location.searchParams.get("page")).toBe("1");
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("GoogleScriptHistoryEvent の state を保持する", () => {
|
|
69
|
-
const source: GoogleScriptHistoryEvent = {
|
|
70
|
-
state: {
|
|
71
|
-
page: 2,
|
|
72
|
-
filters: {
|
|
73
|
-
active: true,
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
location: {
|
|
77
|
-
hash: "/users",
|
|
78
|
-
parameter: {},
|
|
79
|
-
parameters: {},
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const entry = NavigationEntry.fromGoogle(source);
|
|
84
|
-
|
|
85
|
-
expect(entry.state).toEqual({
|
|
86
|
-
page: 2,
|
|
87
|
-
filters: {
|
|
88
|
-
active: true,
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it("hash を正規化可能な HashProperty として生成する", () => {
|
|
94
|
-
const source: GoogleScriptUrlLocation = {
|
|
95
|
-
hash: "users",
|
|
96
|
-
parameter: {},
|
|
97
|
-
parameters: {},
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const entry = NavigationEntry.fromGoogle(source);
|
|
101
|
-
|
|
102
|
-
expect(entry.location.hash.normalize()).toBe("#/users");
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("空の hash をルートとして扱える", () => {
|
|
106
|
-
const source: GoogleScriptUrlLocation = {
|
|
107
|
-
hash: "",
|
|
108
|
-
parameter: {},
|
|
109
|
-
parameters: {},
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const entry = NavigationEntry.fromGoogle(source);
|
|
113
|
-
|
|
114
|
-
expect(entry.location.hash.normalize()).toBe("#/");
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it("単一値の query parameter を searchParams に変換できる", () => {
|
|
118
|
-
const source: GoogleScriptUrlLocation = {
|
|
119
|
-
hash: "/users",
|
|
120
|
-
parameter: {
|
|
121
|
-
page: "2",
|
|
122
|
-
sort: "name",
|
|
123
|
-
},
|
|
124
|
-
parameters: {
|
|
125
|
-
page: ["2"],
|
|
126
|
-
sort: ["name"],
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const entry = NavigationEntry.fromGoogle(source);
|
|
131
|
-
|
|
132
|
-
expect(entry.location.searchParams.get("page")).toBe("2");
|
|
133
|
-
expect(entry.location.searchParams.get("sort")).toBe("name");
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it("同一キーの複数 query parameter を欠損せず searchParams に変換できる", () => {
|
|
137
|
-
const source: GoogleScriptUrlLocation = {
|
|
138
|
-
hash: "/users",
|
|
139
|
-
parameter: {
|
|
140
|
-
tag: "react",
|
|
141
|
-
},
|
|
142
|
-
parameters: {
|
|
143
|
-
tag: ["react", "typescript"],
|
|
144
|
-
},
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
const entry = NavigationEntry.fromGoogle(source);
|
|
148
|
-
|
|
149
|
-
expect(entry.location.searchParams.getAll("tag")).toEqual([
|
|
150
|
-
"react",
|
|
151
|
-
"typescript",
|
|
152
|
-
]);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it("query parameter が存在しない場合は空の searchParams を生成する", () => {
|
|
156
|
-
const source: GoogleScriptUrlLocation = {
|
|
157
|
-
hash: "/users",
|
|
158
|
-
parameter: {},
|
|
159
|
-
parameters: {},
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
const entry = NavigationEntry.fromGoogle(source);
|
|
163
|
-
|
|
164
|
-
expect(entry.location.searchParams.toString()).toBe("");
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
it("同一キーの複数 query parameter の値順を保持する", () => {
|
|
168
|
-
const source: GoogleScriptUrlLocation = {
|
|
169
|
-
hash: "/users",
|
|
170
|
-
parameter: {
|
|
171
|
-
tag: "typescript",
|
|
172
|
-
},
|
|
173
|
-
parameters: {
|
|
174
|
-
tag: ["typescript", "react", "javascript"],
|
|
175
|
-
},
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
const entry = NavigationEntry.fromGoogle(source);
|
|
179
|
-
|
|
180
|
-
expect(entry.location.searchParams.getAll("tag")).toEqual([
|
|
181
|
-
"typescript",
|
|
182
|
-
"react",
|
|
183
|
-
"javascript",
|
|
184
|
-
]);
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it("空文字の query parameter を保持する", () => {
|
|
188
|
-
const source: GoogleScriptUrlLocation = {
|
|
189
|
-
hash: "/users",
|
|
190
|
-
parameter: {
|
|
191
|
-
keyword: "",
|
|
192
|
-
},
|
|
193
|
-
parameters: {
|
|
194
|
-
keyword: [""],
|
|
195
|
-
},
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
const entry = NavigationEntry.fromGoogle(source);
|
|
199
|
-
|
|
200
|
-
expect(entry.location.searchParams.has("keyword")).toBe(true);
|
|
201
|
-
expect(entry.location.searchParams.get("keyword")).toBe("");
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
describe("equals", () => {
|
|
206
|
-
it("state と location が同じ場合は同一と判定できる", () => {
|
|
207
|
-
const left = new NavigationEntry(
|
|
208
|
-
{
|
|
209
|
-
selectedUserId: "123",
|
|
210
|
-
},
|
|
211
|
-
new NavigationLocation(
|
|
212
|
-
new HashProperty("#/users"),
|
|
213
|
-
new URLSearchParams("page=1"),
|
|
214
|
-
),
|
|
215
|
-
);
|
|
216
|
-
|
|
217
|
-
const right = new NavigationEntry(
|
|
218
|
-
{
|
|
219
|
-
selectedUserId: "123",
|
|
220
|
-
},
|
|
221
|
-
new NavigationLocation(
|
|
222
|
-
new HashProperty("#/users"),
|
|
223
|
-
new URLSearchParams("page=1"),
|
|
224
|
-
),
|
|
225
|
-
);
|
|
226
|
-
|
|
227
|
-
expect(left.equals(right)).toBe(true);
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
it("state が異なる場合は異なる entry と判定する", () => {
|
|
231
|
-
const left = new NavigationEntry(
|
|
232
|
-
{
|
|
233
|
-
selectedUserId: "123",
|
|
234
|
-
},
|
|
235
|
-
new NavigationLocation(
|
|
236
|
-
new HashProperty("#/users"),
|
|
237
|
-
new URLSearchParams(),
|
|
238
|
-
),
|
|
239
|
-
);
|
|
240
|
-
|
|
241
|
-
const right = new NavigationEntry(
|
|
242
|
-
{
|
|
243
|
-
selectedUserId: "456",
|
|
244
|
-
},
|
|
245
|
-
new NavigationLocation(
|
|
246
|
-
new HashProperty("#/users"),
|
|
247
|
-
new URLSearchParams(),
|
|
248
|
-
),
|
|
249
|
-
);
|
|
250
|
-
|
|
251
|
-
expect(left.equals(right)).toBe(false);
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it("location が異なる場合は異なる entry と判定する", () => {
|
|
255
|
-
const left = new NavigationEntry(
|
|
256
|
-
{},
|
|
257
|
-
new NavigationLocation(
|
|
258
|
-
new HashProperty("#/users"),
|
|
259
|
-
new URLSearchParams(),
|
|
260
|
-
),
|
|
261
|
-
);
|
|
262
|
-
|
|
263
|
-
const right = new NavigationEntry(
|
|
264
|
-
{},
|
|
265
|
-
new NavigationLocation(
|
|
266
|
-
new HashProperty("#/settings"),
|
|
267
|
-
new URLSearchParams(),
|
|
268
|
-
),
|
|
269
|
-
);
|
|
270
|
-
|
|
271
|
-
expect(left.equals(right)).toBe(false);
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
it("searchParams が異なる場合は異なる entry と判定する", () => {
|
|
275
|
-
const left = new NavigationEntry(
|
|
276
|
-
{},
|
|
277
|
-
new NavigationLocation(
|
|
278
|
-
new HashProperty("#/users"),
|
|
279
|
-
new URLSearchParams("page=1"),
|
|
280
|
-
),
|
|
281
|
-
);
|
|
282
|
-
|
|
283
|
-
const right = new NavigationEntry(
|
|
284
|
-
{},
|
|
285
|
-
new NavigationLocation(
|
|
286
|
-
new HashProperty("#/users"),
|
|
287
|
-
new URLSearchParams("page=2"),
|
|
288
|
-
),
|
|
289
|
-
);
|
|
290
|
-
|
|
291
|
-
expect(left.equals(right)).toBe(false);
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
it("hash の表現が異なっても正規化後の location が同じ場合は同一と判定できる", () => {
|
|
295
|
-
const left = new NavigationEntry(
|
|
296
|
-
{},
|
|
297
|
-
new NavigationLocation(
|
|
298
|
-
new HashProperty("#/users"),
|
|
299
|
-
new URLSearchParams(),
|
|
300
|
-
),
|
|
301
|
-
);
|
|
302
|
-
|
|
303
|
-
const right = new NavigationEntry(
|
|
304
|
-
{},
|
|
305
|
-
new NavigationLocation(
|
|
306
|
-
new HashProperty("/users"),
|
|
307
|
-
new URLSearchParams(),
|
|
308
|
-
),
|
|
309
|
-
);
|
|
310
|
-
|
|
311
|
-
expect(left.equals(right)).toBe(true);
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
it("search parameter のキー順が異なっても同一と判定できる", () => {
|
|
315
|
-
const left = new NavigationEntry(
|
|
316
|
-
{},
|
|
317
|
-
new NavigationLocation(
|
|
318
|
-
new HashProperty("#/users"),
|
|
319
|
-
new URLSearchParams("page=1&sort=name"),
|
|
320
|
-
),
|
|
321
|
-
);
|
|
322
|
-
|
|
323
|
-
const right = new NavigationEntry(
|
|
324
|
-
{},
|
|
325
|
-
new NavigationLocation(
|
|
326
|
-
new HashProperty("#/users"),
|
|
327
|
-
new URLSearchParams("sort=name&page=1"),
|
|
328
|
-
),
|
|
329
|
-
);
|
|
330
|
-
|
|
331
|
-
expect(left.equals(right)).toBe(true);
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
it("同一キーの複数値の順序が異なる場合は異なる entry と判定する", () => {
|
|
335
|
-
const left = new NavigationEntry(
|
|
336
|
-
{},
|
|
337
|
-
new NavigationLocation(
|
|
338
|
-
new HashProperty("#/users"),
|
|
339
|
-
new URLSearchParams("tag=react&tag=typescript"),
|
|
340
|
-
),
|
|
341
|
-
);
|
|
342
|
-
|
|
343
|
-
const right = new NavigationEntry(
|
|
344
|
-
{},
|
|
345
|
-
new NavigationLocation(
|
|
346
|
-
new HashProperty("#/users"),
|
|
347
|
-
new URLSearchParams("tag=typescript&tag=react"),
|
|
348
|
-
),
|
|
349
|
-
);
|
|
350
|
-
|
|
351
|
-
expect(left.equals(right)).toBe(false);
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
it("空の state 同士は同一と判定できる", () => {
|
|
355
|
-
const left = new NavigationEntry(
|
|
356
|
-
{},
|
|
357
|
-
new NavigationLocation(
|
|
358
|
-
new HashProperty("#/users"),
|
|
359
|
-
new URLSearchParams(),
|
|
360
|
-
),
|
|
361
|
-
);
|
|
362
|
-
|
|
363
|
-
const right = new NavigationEntry(
|
|
364
|
-
{},
|
|
365
|
-
new NavigationLocation(
|
|
366
|
-
new HashProperty("#/users"),
|
|
367
|
-
new URLSearchParams(),
|
|
368
|
-
),
|
|
369
|
-
);
|
|
370
|
-
|
|
371
|
-
expect(left.equals(right)).toBe(true);
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
it("state のプロパティ数が異なる場合は異なる entry と判定する", () => {
|
|
375
|
-
const left = new NavigationEntry(
|
|
376
|
-
{
|
|
377
|
-
page: 1,
|
|
378
|
-
},
|
|
379
|
-
new NavigationLocation(
|
|
380
|
-
new HashProperty("#/users"),
|
|
381
|
-
new URLSearchParams(),
|
|
382
|
-
),
|
|
383
|
-
);
|
|
384
|
-
|
|
385
|
-
const right = new NavigationEntry(
|
|
386
|
-
{
|
|
387
|
-
page: 1,
|
|
388
|
-
selected: true,
|
|
389
|
-
},
|
|
390
|
-
new NavigationLocation(
|
|
391
|
-
new HashProperty("#/users"),
|
|
392
|
-
new URLSearchParams(),
|
|
393
|
-
),
|
|
394
|
-
);
|
|
395
|
-
|
|
396
|
-
expect(left.equals(right)).toBe(false);
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
it("ネストした state が同じ場合は同一と判定できる", () => {
|
|
400
|
-
const left = new NavigationEntry(
|
|
401
|
-
{
|
|
402
|
-
filters: {
|
|
403
|
-
category: "user",
|
|
404
|
-
active: true,
|
|
405
|
-
},
|
|
406
|
-
},
|
|
407
|
-
new NavigationLocation(
|
|
408
|
-
new HashProperty("#/users"),
|
|
409
|
-
new URLSearchParams(),
|
|
410
|
-
),
|
|
411
|
-
);
|
|
412
|
-
|
|
413
|
-
const right = new NavigationEntry(
|
|
414
|
-
{
|
|
415
|
-
filters: {
|
|
416
|
-
category: "user",
|
|
417
|
-
active: true,
|
|
418
|
-
},
|
|
419
|
-
},
|
|
420
|
-
new NavigationLocation(
|
|
421
|
-
new HashProperty("#/users"),
|
|
422
|
-
new URLSearchParams(),
|
|
423
|
-
),
|
|
424
|
-
);
|
|
425
|
-
|
|
426
|
-
expect(left.equals(right)).toBe(true);
|
|
427
|
-
});
|
|
428
|
-
|
|
429
|
-
it("ネストした state の値が異なる場合は異なる entry と判定する", () => {
|
|
430
|
-
const left = new NavigationEntry(
|
|
431
|
-
{
|
|
432
|
-
filters: {
|
|
433
|
-
active: true,
|
|
434
|
-
},
|
|
435
|
-
},
|
|
436
|
-
new NavigationLocation(
|
|
437
|
-
new HashProperty("#/users"),
|
|
438
|
-
new URLSearchParams(),
|
|
439
|
-
),
|
|
440
|
-
);
|
|
441
|
-
|
|
442
|
-
const right = new NavigationEntry(
|
|
443
|
-
{
|
|
444
|
-
filters: {
|
|
445
|
-
active: false,
|
|
446
|
-
},
|
|
447
|
-
},
|
|
448
|
-
new NavigationLocation(
|
|
449
|
-
new HashProperty("#/users"),
|
|
450
|
-
new URLSearchParams(),
|
|
451
|
-
),
|
|
452
|
-
);
|
|
453
|
-
|
|
454
|
-
expect(left.equals(right)).toBe(false);
|
|
455
|
-
});
|
|
456
|
-
|
|
457
|
-
it("state のオブジェクトのキー順が異なっても同一と判定できる", () => {
|
|
458
|
-
const left = new NavigationEntry(
|
|
459
|
-
{
|
|
460
|
-
page: 1,
|
|
461
|
-
selected: true,
|
|
462
|
-
},
|
|
463
|
-
new NavigationLocation(
|
|
464
|
-
new HashProperty("#/users"),
|
|
465
|
-
new URLSearchParams(),
|
|
466
|
-
),
|
|
467
|
-
);
|
|
468
|
-
|
|
469
|
-
const right = new NavigationEntry(
|
|
470
|
-
{
|
|
471
|
-
selected: true,
|
|
472
|
-
page: 1,
|
|
473
|
-
},
|
|
474
|
-
new NavigationLocation(
|
|
475
|
-
new HashProperty("#/users"),
|
|
476
|
-
new URLSearchParams(),
|
|
477
|
-
),
|
|
478
|
-
);
|
|
479
|
-
|
|
480
|
-
expect(left.equals(right)).toBe(true);
|
|
481
|
-
});
|
|
482
|
-
|
|
483
|
-
it("state の配列は値の順序を区別する", () => {
|
|
484
|
-
const left = new NavigationEntry(
|
|
485
|
-
{
|
|
486
|
-
ids: ["1", "2"],
|
|
487
|
-
},
|
|
488
|
-
new NavigationLocation(
|
|
489
|
-
new HashProperty("#/users"),
|
|
490
|
-
new URLSearchParams(),
|
|
491
|
-
),
|
|
492
|
-
);
|
|
493
|
-
|
|
494
|
-
const right = new NavigationEntry(
|
|
495
|
-
{
|
|
496
|
-
ids: ["2", "1"],
|
|
497
|
-
},
|
|
498
|
-
new NavigationLocation(
|
|
499
|
-
new HashProperty("#/users"),
|
|
500
|
-
new URLSearchParams(),
|
|
501
|
-
),
|
|
502
|
-
);
|
|
503
|
-
|
|
504
|
-
expect(left.equals(right)).toBe(false);
|
|
505
|
-
});
|
|
506
|
-
});
|
|
507
|
-
});
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { HashProperty } from "../src/navigation/HashProperty";
|
|
3
|
-
import { NavigationLocation } from "../src/navigation/NavigationLocation";
|
|
4
|
-
|
|
5
|
-
describe("NavigationLocation", () => {
|
|
6
|
-
describe("equals", () => {
|
|
7
|
-
it("hash と searchParams が同じ場合は同一と判定できる", () => {
|
|
8
|
-
const left = new NavigationLocation(
|
|
9
|
-
new HashProperty("#/users"),
|
|
10
|
-
new URLSearchParams("page=1&sort=name"),
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
const right = new NavigationLocation(
|
|
14
|
-
new HashProperty("#/users"),
|
|
15
|
-
new URLSearchParams("page=1&sort=name"),
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
expect(left.equals(right)).toBe(true);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("表現が異なっても正規化後の hash が同じ場合は同一と判定できる", () => {
|
|
22
|
-
const left = new NavigationLocation(
|
|
23
|
-
new HashProperty("#/users"),
|
|
24
|
-
new URLSearchParams(),
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
const right = new NavigationLocation(
|
|
28
|
-
new HashProperty("/users"),
|
|
29
|
-
new URLSearchParams(),
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
expect(left.equals(right)).toBe(true);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("hash が異なる場合は異なる location と判定する", () => {
|
|
36
|
-
const left = new NavigationLocation(
|
|
37
|
-
new HashProperty("#/users"),
|
|
38
|
-
new URLSearchParams(),
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
const right = new NavigationLocation(
|
|
42
|
-
new HashProperty("#/settings"),
|
|
43
|
-
new URLSearchParams(),
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
expect(left.equals(right)).toBe(false);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("searchParams の値が異なる場合は異なる location と判定する", () => {
|
|
50
|
-
const left = new NavigationLocation(
|
|
51
|
-
new HashProperty("#/users"),
|
|
52
|
-
new URLSearchParams("page=1"),
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
const right = new NavigationLocation(
|
|
56
|
-
new HashProperty("#/users"),
|
|
57
|
-
new URLSearchParams("page=2"),
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
expect(left.equals(right)).toBe(false);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("searchParams のキー順が異なっても同一と判定できる", () => {
|
|
64
|
-
const left = new NavigationLocation(
|
|
65
|
-
new HashProperty("#/users"),
|
|
66
|
-
new URLSearchParams("page=1&sort=name"),
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
const right = new NavigationLocation(
|
|
70
|
-
new HashProperty("#/users"),
|
|
71
|
-
new URLSearchParams("sort=name&page=1"),
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
expect(left.equals(right)).toBe(true);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it("同一キーに複数値がある場合は値の順序を区別する", () => {
|
|
78
|
-
const left = new NavigationLocation(
|
|
79
|
-
new HashProperty("#/users"),
|
|
80
|
-
new URLSearchParams("tag=react&tag=typescript"),
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
const right = new NavigationLocation(
|
|
84
|
-
new HashProperty("#/users"),
|
|
85
|
-
new URLSearchParams("tag=typescript&tag=react"),
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
expect(left.equals(right)).toBe(false);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("同一キーに複数値があり値の順序も同じ場合は同一と判定できる", () => {
|
|
92
|
-
const left = new NavigationLocation(
|
|
93
|
-
new HashProperty("#/users"),
|
|
94
|
-
new URLSearchParams("tag=react&tag=typescript"),
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
const right = new NavigationLocation(
|
|
98
|
-
new HashProperty("#/users"),
|
|
99
|
-
new URLSearchParams("tag=react&tag=typescript"),
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
expect(left.equals(right)).toBe(true);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("片方にのみ search parameter が存在する場合は異なる location と判定する", () => {
|
|
106
|
-
const left = new NavigationLocation(
|
|
107
|
-
new HashProperty("#/users"),
|
|
108
|
-
new URLSearchParams("page=1"),
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
const right = new NavigationLocation(
|
|
112
|
-
new HashProperty("#/users"),
|
|
113
|
-
new URLSearchParams(),
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
expect(left.equals(right)).toBe(false);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it("search parameter のキー数が異なる場合は異なる location と判定する", () => {
|
|
120
|
-
const left = new NavigationLocation(
|
|
121
|
-
new HashProperty("#/users"),
|
|
122
|
-
new URLSearchParams("page=1"),
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
const right = new NavigationLocation(
|
|
126
|
-
new HashProperty("#/users"),
|
|
127
|
-
new URLSearchParams("page=1&sort=name"),
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
expect(left.equals(right)).toBe(false);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it("空の searchParams 同士は同一と判定できる", () => {
|
|
134
|
-
const left = new NavigationLocation(
|
|
135
|
-
new HashProperty("#/users"),
|
|
136
|
-
new URLSearchParams(),
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
const right = new NavigationLocation(
|
|
140
|
-
new HashProperty("#/users"),
|
|
141
|
-
new URLSearchParams(),
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
expect(left.equals(right)).toBe(true);
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it("空文字の値を持つ parameter と parameter が存在しない状態を区別する", () => {
|
|
148
|
-
const left = new NavigationLocation(
|
|
149
|
-
new HashProperty("#/users"),
|
|
150
|
-
new URLSearchParams("tag="),
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
const right = new NavigationLocation(
|
|
154
|
-
new HashProperty("#/users"),
|
|
155
|
-
new URLSearchParams(),
|
|
156
|
-
);
|
|
157
|
-
|
|
158
|
-
expect(left.equals(right)).toBe(false);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it("同じ空文字の値を持つ parameter は同一と判定できる", () => {
|
|
162
|
-
const left = new NavigationLocation(
|
|
163
|
-
new HashProperty("#/users"),
|
|
164
|
-
new URLSearchParams("tag="),
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
const right = new NavigationLocation(
|
|
168
|
-
new HashProperty("#/users"),
|
|
169
|
-
new URLSearchParams("tag="),
|
|
170
|
-
);
|
|
171
|
-
|
|
172
|
-
expect(left.equals(right)).toBe(true);
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
it("hash と searchParams の両方が異なる場合は異なる location と判定する", () => {
|
|
176
|
-
const left = new NavigationLocation(
|
|
177
|
-
new HashProperty("#/users"),
|
|
178
|
-
new URLSearchParams("page=1"),
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
const right = new NavigationLocation(
|
|
182
|
-
new HashProperty("#/settings"),
|
|
183
|
-
new URLSearchParams("page=2"),
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
expect(left.equals(right)).toBe(false);
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
});
|
package/tests/setup.ts
DELETED