-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRouter.specs.js
564 lines (525 loc) · 27.1 KB
/
Router.specs.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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
// Example
// OnRoute({route: 'group/:groupId'}, [
// showGroupCore,
// OnRoute({route: 'user/:userId'}, [
// showUsersCore,
// showUserDetails
// ])
// ]);
// Test plan
// - Test Universe = Settings x ChildrenComponents x SequenceOfRoutes
// Note that the first two sets correspond to the specification of the Router component factory,
// while the remaining sets correspond to the specification of the Router component itself.
// We will discard testing for Settings and ChildrenComponents by assuming independence and good
// behaviour (T1, T4).
// We further reduce the universe under test by observing that the component behaviour should
// deoend on the route transitions (T2) and there are only a few types of such transitions within
// which the behaviour should be homogeneous (T3). The absence of recomputation for two
// similar route partial match will tested independently of the rest (T1). As the
// nesting level is also an important part of the routing specification, we will test up to a
// nesting level of 2, which should cover practical cases (T4). The test universe is in summary
// reduced to the following :
// - Test Universe = TransitionTypes x NestingLevel x ParameterParsing x NoopWhenRepeatRoute
// We will test ParameterParsing along the way (T1) and NoopWhenRepeatRoute separately and
// independently (T1). We then have :
// - Test Universe = TransitionTypes x NestingLevel + NoopWhenRepeatRoute
// NOTE : In all rigour, I should add also the requirements described in behaviour in the
// documentation, and relating to sink merging of children components, the parameter passing
// to the children via `matched` property, and the pruning of `route` source. I will incorporate
// that in the tests without talking about it.
import * as QUnit from "qunitjs"
import { OnRoute } from '../src/components/Router/Router'
import { m } from '../src/components/m/m'
import * as Rx from 'rx'
import { h } from 'cycle-snabbdom'
import { runTestScenario } from '../testing/src/runTestScenario'
import { convertVNodesToHTML, format } from "../utils/src/index"
import { DOM_SINK } from "../utils/src/index"
import { pipe } from 'ramda'
import { ROUTE_PARAMS } from "../src/components/Router/properties"
const $ = Rx.Observable;
function analyzeTestResults(assert, done) {
return function analyzeTestResults(actual, expected, message) {
assert.deepEqual(actual, expected, message);
done()
}
}
const NON_DOM_SINK = 'a';
const ANOTHER_NON_DOM_SINK = 'b';
const A_SOURCE = 'DOM1';
const ANOTHER_SOURCE = 'DOM2';
const ROUTE_LOG_SINK = 'ROUTE_LOG';
const ROUTE_SOURCE = 'route$';
function makeTestHelperComponent(header, sourceName, routeCfg) {
return function (sources, settings) {
return {
// NOTE : that DOM example is a bit fictitious as DOM should ALWAYS have a starting value...
// We keep it like this though for testing purposes
[DOM_SINK]: sources[sourceName].map(x => h('span', {},
`${header} on route '${routeCfg}' > ${ROUTE_PARAMS} - ${sourceName}: ${format(settings[ROUTE_PARAMS])} - ${x}`)),
// NOTE : x here will be the route remainder vs. current match
[ROUTE_LOG_SINK]: sources[ROUTE_SOURCE]
.map(x => `${header} on route '${routeCfg}' > ${ROUTE_PARAMS} - route remainder : `
+ format(settings[ROUTE_PARAMS]) + ' - ' + x),
[NON_DOM_SINK]: sources.userAction$
.map(x => `${header} on route '${routeCfg}' > ${NON_DOM_SINK} > user action : `
+ format(x))
}
}
}
function getHelperComponentOutput(header, sourceName, routeCfg, routeParams, x) {
return {
[DOM_SINK]: `<span>${header} on route '${routeCfg}' > ${ROUTE_PARAMS} - ${sourceName}: ${format(routeParams)} - ${x}</span>`,
[NON_DOM_SINK]: `${header} on route '${routeCfg}' > ${NON_DOM_SINK} > user action : ${format(x)}`,
[ROUTE_LOG_SINK]: `${header} on route '${routeCfg}' > ${ROUTE_PARAMS} - route remainder : ${format(routeParams)} - ${x}`
}
}
function divwrap(str) {
return str ? `<div>${str}</div>` : ''
}
QUnit.module("Testing Router component", {});
// A. with no nesting (only first should match and /anything should be configured but not the rest)
// - / -> /group -> /other -> /anything/else/there -> /
QUnit.test("non-nested routing - transitions - initial state", function exec_test(assert) {
const done = assert.async(3);
const sinkNames = [DOM_SINK, NON_DOM_SINK, ROUTE_LOG_SINK];
const routerComponent = m({}, { sinkNames: sinkNames, routeSource: ROUTE_SOURCE }, [
OnRoute({ route: 'group' }, [
makeTestHelperComponent('Component 1', A_SOURCE, 'group'),
makeTestHelperComponent('Component 2', ANOTHER_SOURCE, 'group'),
]),
]);
const inputs = [
{ DOM1: { diagram: '-------------------------' } },
{ DOM2: { diagram: '------------------------' } },
{
userAction$: {
diagram: 'a---b-ac--ab---c',
values: { a: 'click', b: 'select', c: 'hover', }
}
},
{
route$: {
diagram: '-------a----', values: {
a: 'D',
b: 'group',
c: 'other',
d: 'anything/else/there',
}
}
}
];
const expected = {
[DOM_SINK]: {
outputs: [null],
successMessage: `sink ${DOM_SINK} produces only null : transition match -> non-match immediately produces null on DOM sink as first value AND initial state counts as match (starting the router)`,
transform: pipe(convertVNodesToHTML),
},
[NON_DOM_SINK]: {
outputs: [],
successMessage: `sink ${NON_DOM_SINK} produces the expected values`,
},
[ROUTE_LOG_SINK]: {
outputs: [],
successMessage: `sink ${ROUTE_LOG_SINK} produces no values as expected! There was no match`,
},
};
runTestScenario(inputs, expected, routerComponent, {
tickDuration: 3,
waitForFinishDelay: 10,
analyzeTestResults: analyzeTestResults(assert, done),
errorHandler: function (err) {
done(err)
}
});
});
QUnit.test("non-nested routing - transitions no match -> match", function exec_test(assert) {
const done = assert.async(3);
const sinkNames = [DOM_SINK, NON_DOM_SINK, ROUTE_LOG_SINK];
const routerComponent = m({}, { sinkNames: sinkNames, routeSource: ROUTE_SOURCE }, [
OnRoute({ route: 'group' }, [
makeTestHelperComponent('Component 1', A_SOURCE, 'group'),
makeTestHelperComponent('Component 2', ANOTHER_SOURCE, 'group'),
]),
]);
const inputs = [
{ DOM1: { diagram: '-a--b--c------------------' } },
{ DOM2: { diagram: '-a-b-c-d-----------------' } },
{
userAction$: {
diagram: '----------------',
values: { a: 'click', b: 'select', c: 'hover', }
}
},
{
route$: {
// DOM1: '-a--b--c--d--e--f--a--b--c--d-'}},
// DOM2: '-a-b-c-d-e-f-abb-c-d-e-f-'}},
diagram: '-----b------', values: {
a: '',
b: 'group',
c: 'other',
d: 'anything/else/there',
}
}
}
];
const expected = {
[DOM_SINK]: {
outputs: [
null,
divwrap(divwrap(`${getHelperComponentOutput('Component 1', A_SOURCE, 'group', {}, 'c')[DOM_SINK]}${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'group', {}, 'd')[DOM_SINK]}`))
],
successMessage: `sink ${DOM_SINK} : transition any -> match produces a null value as the first value of the DOM sink, then the regular DOM sinks as computed from the component`,
transform: pipe(convertVNodesToHTML),
},
[NON_DOM_SINK]: {
outputs: [],
successMessage: `sink ${NON_DOM_SINK} produces the expected values`,
},
[ROUTE_LOG_SINK]: {
outputs: [
`${getHelperComponentOutput('Component 1', A_SOURCE, 'group', {}, undefined)[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'group', {}, undefined)[ROUTE_LOG_SINK]}`
],
successMessage: `sink ${ROUTE_LOG_SINK} produces the expected values`,
},
};
runTestScenario(inputs, expected, routerComponent, {
tickDuration: 3,
waitForFinishDelay: 10,
analyzeTestResults: analyzeTestResults(assert, done),
errorHandler: function (err) {
done(err)
}
});
});
QUnit.test("non-nested routing - transitions match -> no match, also testing param parsing", function exec_test(assert) {
const done = assert.async(3);
const sinkNames = [DOM_SINK, NON_DOM_SINK, ROUTE_LOG_SINK];
const routerComponent = m({}, { sinkNames: sinkNames, routeSource: ROUTE_SOURCE }, [
OnRoute({ route: 'group:param' }, [
makeTestHelperComponent('Component 1', A_SOURCE, 'group:param'),
makeTestHelperComponent('Component 2', ANOTHER_SOURCE, 'group:param'),
]),
]);
const inputs = [
{ DOM1: { diagram: '-a--b--c------------------' } },
{ DOM2: { diagram: '-a-b-c-d-----------------' } },
{
userAction$: {
diagram: '----------------',
values: { a: 'click', b: 'select', c: 'hover', }
}
},
{
route$: {
// DOM1: '-a--b--c--d--e--f--a--b--c--d-'}},
// DOM2: '-a-b-c-d-e-f-abb-c-d-e-f-'}},
diagram: '-----b--c---', values: {
a: '',
b: 'group?paramKey=paramValue',
c: 'other',
d: 'anything/else/there',
}
}
}
];
const expected = {
[DOM_SINK]: {
outputs: [
null,
divwrap(divwrap(`${getHelperComponentOutput('Component 1', A_SOURCE, 'group:param', { param: '?paramKey=paramValue' }, 'c')[DOM_SINK]}${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'group:param', { param: '?paramKey=paramValue' }, 'd')[DOM_SINK]}`)),
// NOTE : extra null triggered by transition match -> no match
null
],
successMessage: `sink ${DOM_SINK} : transition any -> match produces a null value as the first value of the DOM sink, then the regular DOM sinks as computed from the component`,
transform: pipe(convertVNodesToHTML),
},
[NON_DOM_SINK]: {
outputs: [],
successMessage: `sink ${NON_DOM_SINK} produces the expected values`,
},
[ROUTE_LOG_SINK]: {
outputs: [
`${getHelperComponentOutput('Component 1', A_SOURCE, 'group:param', { param: '?paramKey=paramValue' }, undefined)[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'group:param', { param: '?paramKey=paramValue' }, undefined)[ROUTE_LOG_SINK]}`
],
successMessage: `sink ${ROUTE_LOG_SINK} produces the expected values`,
},
};
runTestScenario(inputs, expected, routerComponent, {
tickDuration: 3,
waitForFinishDelay: 10,
analyzeTestResults: analyzeTestResults(assert, done),
errorHandler: function (err) {
done(err)
}
});
});
QUnit.test("non-nested routing - transitions", function exec_test(assert) {
const done = assert.async(3);
const sinkNames = [DOM_SINK, NON_DOM_SINK, ROUTE_LOG_SINK];
const routerComponent = m({}, { sinkNames: sinkNames, routeSource: ROUTE_SOURCE }, [
OnRoute({ route: 'group' }, [
makeTestHelperComponent('Component 1', A_SOURCE, 'group'),
makeTestHelperComponent('Component 2', ANOTHER_SOURCE, 'group'),
]),
OnRoute({ route: 'anything' }, [
makeTestHelperComponent('Component 1', A_SOURCE, 'anything'),
makeTestHelperComponent('Component 2', ANOTHER_SOURCE, 'anything'),
]),
]);
const inputs = [
{ DOM1: { diagram: '-a--b--c--d--e------------' } },
{ DOM2: { diagram: '-a-b-c-d-e-f--------' } },
{
userAction$: {
diagram: 'a---b-ac--ab---c',
values: { a: 'click', b: 'select', c: 'hover', }
}
},
{
route$: {
// DOM1: '-a--b--c--d--e------------'}},
// DOM2: '-a-b-c-d-e-f--------'}},
// user: 'a---b-ac--ab---c', { a: 'click', b: 'select', c: 'hover', }
diagram: '-a---b--cd--', values: {
a: '',
b: 'group',
c: 'other',
d: 'anything/else/there',
}
}
}
];
const expected = {
[DOM_SINK]: {
outputs: [
null, // transition init -> no match
null, // match starts with null
divwrap(divwrap(`${getHelperComponentOutput('Component 1', A_SOURCE, 'group', {}, 'c')[DOM_SINK]}${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'group', {}, 'd')[DOM_SINK]}`)),
null, // transition match -> no match
null, // match starts with null
divwrap(divwrap(`${getHelperComponentOutput('Component 1', A_SOURCE, 'anything', {}, 'd')[DOM_SINK]}${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'anything', {}, 'f')[DOM_SINK]}`)),
divwrap(divwrap(`${getHelperComponentOutput('Component 1', A_SOURCE, 'anything', {}, 'e')[DOM_SINK]}${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'anything', {}, 'f')[DOM_SINK]}`)),
],
successMessage: `sink ${DOM_SINK} produces the expected values`,
transform: pipe(convertVNodesToHTML),
},
[NON_DOM_SINK]: {
outputs: [
`${getHelperComponentOutput('Component 1', A_SOURCE, 'group', {}, 'click')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'group', {}, 'click')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Component 1', A_SOURCE, 'group', {}, 'hover')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'group', {}, 'hover')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Component 1', A_SOURCE, 'anything', {}, 'click')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'anything', {}, 'click')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Component 1', A_SOURCE, 'anything', {}, 'select')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'anything', {}, 'select')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Component 1', A_SOURCE, 'anything', {}, 'hover')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'anything', {}, 'hover')[NON_DOM_SINK]}`,
],
successMessage: `sink ${NON_DOM_SINK} produces the expected values`,
},
[ROUTE_LOG_SINK]: {
outputs: [
`${getHelperComponentOutput('Component 1', A_SOURCE, 'group', {}, undefined)[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'group', {}, undefined)[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Component 1', A_SOURCE, 'anything', {}, 'else/there')[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'anything', {}, 'else/there')[ROUTE_LOG_SINK]}`,
],
successMessage: `sink ${ROUTE_LOG_SINK} produces the expected values`,
},
};
runTestScenario(inputs, expected, routerComponent, {
tickDuration: 3,
waitForFinishDelay: 10,
analyzeTestResults: analyzeTestResults(assert, done),
errorHandler: function (err) {
done(err)
}
});
});
// B. with one nesting to test (group and other configured, then page:... configured)
// Transitions
// NOTE : A = 'anything', Parent = 'master', Child = 'Detail'
// 1. x -> Parent,
// 2. x -> Parent, Child,
// 3. x-> x,
// 4. Parent -> Parent, Child,
// 5. Parent -> Parent;
// 6. Parent, Child -> Parent, Child ;
// 7. Parent, Child -> Parent ;
// 8. Parent, Child -> x
// 9. x -> A,
// 10. A -> A,
// 11. A -> x
// 12. A -> Parent,
// 13. A -> Parent, Child ;
// 14. Parent, Child -> A,
// 15. Parent -> A
// - / -> /master -> /master/ -> /master/detail?name=ferret&color=purple -> /master/ -> /master-> /
// - / -> /master/detail?name=ferret&color=purple -> /master/detail?name=ferret&color=red -> /
// - /master/detail?name=ferret&color=purple -> /other/page?name=ferret&color=red -> /
QUnit.test("nested routing depth 1 - transitions", function exec_test(assert) {
const done = assert.async(3);
const sinkNames = [DOM_SINK, NON_DOM_SINK, ROUTE_LOG_SINK];
const routerComponent = m({}, { sinkNames: sinkNames, routeSource: ROUTE_SOURCE }, [
OnRoute({ route: 'master:qs' }, [
makeTestHelperComponent('Master component', A_SOURCE, 'master'),
OnRoute({ route: 'detail:qs' }, [
makeTestHelperComponent('Detail component', ANOTHER_SOURCE, 'detail:qs'),
])
]),
OnRoute({ route: 'anything' }, [
makeTestHelperComponent('Component 1', A_SOURCE, 'anything'),
makeTestHelperComponent('Component 2', ANOTHER_SOURCE, 'anything'),
]),
]);
const inputs = [
{ DOM1: { diagram: '-a--b--c--d--e--f--g--h--i--j--k--l--m' } },
{ DOM2: { diagram: '-a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s' } },
{
userAction$: {
diagram: 'a---b-ac--ab---c-b-c-aab---c--a-b',
values: { a: 'click', b: 'select', c: 'hover', }
}
},
{
route$: {
// DOM1: '-a--b--c--d--e--f--g--h--i--j--k--l--m'}},
// DOM2: '-a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s'}},
// user: 'a---b-ac--ab---c-b-c-aab---c--a-b', { a: 'click', b: 'select', c: 'hover', }
diagram: '-a-g--b-d--e-c--b-f-f-d-f-a-f-b-g-d', values: {
// transition ab, bd, de, ec, cb, bf, ff, fd, df, fa, af, fb, ba, gd,
// a=g, b=c, d=e, that results in the following diagram
// a-g-b-d-e-c-b-f-f-d-f-a-f-b-g-d
a: '',
b: 'master',
c: 'master?queryStringMaster',
d: 'master/detail?queryStringDetail1',
e: 'master/detail?queryStringDetail2/extrasection',
f: 'anything',
g: 'nomatch'
}
}
}
];
const expected = {
[DOM_SINK]: {
outputs: [
null, // init -> no match
// no match -> no match = nothing
null, // match starts with null
divwrap(divwrap(`${getHelperComponentOutput('Master component', A_SOURCE, 'master', { qs: '' }, 'c')[DOM_SINK]}`)),
// match -> match same section = repeats?
divwrap(divwrap(`${getHelperComponentOutput('Master component', A_SOURCE, 'master', { qs: '' }, 'c')[DOM_SINK]}`)),
divwrap(divwrap(`${getHelperComponentOutput('Master component', A_SOURCE, 'master', { qs: '' }, 'c')[DOM_SINK]}${divwrap(getHelperComponentOutput('Detail component', ANOTHER_SOURCE, 'detail:qs', { qs: '?queryStringDetail1' }, 'e')[DOM_SINK])}`)),
divwrap(divwrap(`${getHelperComponentOutput('Master component', A_SOURCE, 'master', { qs: '' }, 'd')[DOM_SINK]}${divwrap(getHelperComponentOutput('Detail component', ANOTHER_SOURCE, 'detail:qs', { qs: '?queryStringDetail1' }, 'e')[DOM_SINK])}`)),
divwrap(divwrap(`${getHelperComponentOutput('Master component', A_SOURCE, 'master', { qs: '' }, 'd')[DOM_SINK]}${divwrap(getHelperComponentOutput('Detail component', ANOTHER_SOURCE, 'detail:qs', { qs: '?queryStringDetail1' }, 'f')[DOM_SINK])}`)),
// match -< match on child, child DOM will starts with null, so parent will be repeating
// former value = d
divwrap(divwrap(`${getHelperComponentOutput('Master component', A_SOURCE, 'master', { qs: '' }, 'd')[DOM_SINK]}`)),
divwrap(divwrap(`${getHelperComponentOutput('Master component', A_SOURCE, 'master', { qs: '' }, 'e')[DOM_SINK]}`)),
divwrap(divwrap(`${getHelperComponentOutput('Master component', A_SOURCE, 'master', { qs: '' }, 'e')[DOM_SINK]}${divwrap(getHelperComponentOutput('Detail component', ANOTHER_SOURCE, 'detail:qs', { qs: '?queryStringDetail2' }, 'g')[DOM_SINK])}`)),
null, // master vs. master?xx are different sections -> resets to null
divwrap(divwrap(`${getHelperComponentOutput('Master component', A_SOURCE, 'master', { qs: '?queryStringMaster' }, 'f')[DOM_SINK]}`)),
null,// // master vs. master?xx are different sections -> resets to null
// master vs. anything -> null, null.
// 1. null to finish master, combinedLatest with null on anything branch (never was
// nothing but null so far)
// 2. then null to start anything branch, combinedLatest with null on master branch
null,
null,
divwrap(divwrap(`${getHelperComponentOutput('Component 1', A_SOURCE, 'anything', {}, 'g')[DOM_SINK]}${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'anything', {}, 'j')[DOM_SINK]}`)),
divwrap(divwrap(`${getHelperComponentOutput('Component 1', A_SOURCE, 'anything', {}, 'g')[DOM_SINK]}${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'anything', {}, 'k')[DOM_SINK]}`)),
divwrap(divwrap(`${getHelperComponentOutput('Component 1', A_SOURCE, 'anything', {}, 'h')[DOM_SINK]}${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'anything', {}, 'k')[DOM_SINK]}`)),
// d => match on master branch -> null there combinedLAtest with anything branch -> repeats
divwrap(divwrap(`${getHelperComponentOutput('Component 1', A_SOURCE, 'anything', {}, 'h')[DOM_SINK]}${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'anything', {}, 'k')[DOM_SINK]}`)),
// then anything branch no match -> null (if anything branch was before master branch
// would not happen i.e. this is subscription-order dependent) but eventually all is well
null,
// then l on child does not produce anything (have nothing in parent so nothing emited
// by combineLatest)
// then moving back to anything reproduces double null by the same reasoning as before
null,
null,
divwrap(divwrap(`${getHelperComponentOutput('Component 1', A_SOURCE, 'anything', {}, 'i')[DOM_SINK]}${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'anything', {}, 'm')[DOM_SINK]}`)),
null,
null, // because of transition a -> f
null, // double null because of f-> b
null,
divwrap(divwrap(`${getHelperComponentOutput('Master component', A_SOURCE, 'master', { qs: '' }, 'k')[DOM_SINK]}`)),
null,
null,
divwrap(divwrap(`${getHelperComponentOutput('Master component', A_SOURCE, 'master', { qs: '' }, 'm')[DOM_SINK]}${divwrap(getHelperComponentOutput('Detail component', ANOTHER_SOURCE, 'detail:qs', { qs: '?queryStringDetail1' }, 'r')[DOM_SINK])}`)),
divwrap(divwrap(`${getHelperComponentOutput('Master component', A_SOURCE, 'master', { qs: '' }, 'm')[DOM_SINK]}${divwrap(getHelperComponentOutput('Detail component', ANOTHER_SOURCE, 'detail:qs', { qs: '?queryStringDetail1' }, 's')[DOM_SINK])}`)),
],
successMessage: `sink ${DOM_SINK} produces the expected values`,
transform: pipe(convertVNodesToHTML),
},
[NON_DOM_SINK]: {
outputs: [
`${getHelperComponentOutput('Master component', A_SOURCE, 'master', {}, 'hover')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Master component', A_SOURCE, 'master', {}, 'click')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Detail component', A_SOURCE, 'detail:qs', {}, 'click')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Master component', A_SOURCE, 'master', {}, 'select')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Detail component', A_SOURCE, 'detail:qs', {}, 'select')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Master component', A_SOURCE, 'master', {}, 'hover')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Master component', A_SOURCE, 'master', {}, 'select')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Component 1', A_SOURCE, 'anything', {}, 'hover')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'anything', {}, 'hover')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Component 1', A_SOURCE, 'anything', {}, 'click')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'anything', {}, 'click')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Component 1', A_SOURCE, 'anything', {}, 'click')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'anything', {}, 'click')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Master component', A_SOURCE, 'master', {}, 'select')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Detail component', A_SOURCE, 'detail:qs', {}, 'select')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Component 1', A_SOURCE, 'anything', {}, 'click')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'anything', {}, 'click')[NON_DOM_SINK]}`,
`${getHelperComponentOutput('Master component', A_SOURCE, 'master', {}, 'select')[NON_DOM_SINK]}`,
],
successMessage: `sink ${NON_DOM_SINK} produces the expected values`,
},
[ROUTE_LOG_SINK]: {
outputs: [
`${getHelperComponentOutput('Master component', A_SOURCE, 'master', { qs: '' }, undefined)[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Master component', A_SOURCE, 'master', { qs: '' }, 'detail?queryStringDetail1')[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Detail component', ANOTHER_SOURCE, 'detail:qs', { qs: '?queryStringDetail1' }, undefined)[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Master component', A_SOURCE, 'master', { qs: '' }, 'detail?queryStringDetail2/extrasection')[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Detail component', ANOTHER_SOURCE, 'detail:qs', { qs: '?queryStringDetail2' }, 'extrasection')[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Master component', A_SOURCE, 'master', { qs: '?queryStringMaster' }, undefined)[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Master component', A_SOURCE, 'master', { qs: '' }, undefined)[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Component 1', A_SOURCE, 'anything', {}, undefined)[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'anything', {}, undefined)[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Component 1', A_SOURCE, 'anything', {}, undefined)[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'anything', {}, undefined)[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Master component', A_SOURCE, 'master', { qs: '' }, 'detail?queryStringDetail1')[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Detail component', ANOTHER_SOURCE, 'detail:qs', { qs: '?queryStringDetail1' }, undefined)[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Component 1', A_SOURCE, 'anything', {}, undefined)[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'anything', {}, undefined)[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Component 1', A_SOURCE, 'anything', {}, undefined)[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Component 2', ANOTHER_SOURCE, 'anything', {}, undefined)[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Master component', A_SOURCE, 'master', { qs: '' }, undefined)[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Master component', A_SOURCE, 'master', { qs: '' }, 'detail?queryStringDetail1')[ROUTE_LOG_SINK]}`,
`${getHelperComponentOutput('Detail component', ANOTHER_SOURCE, 'detail:qs', { qs: '?queryStringDetail1' }, undefined)[ROUTE_LOG_SINK]}`,
],
successMessage: `sink ${ROUTE_LOG_SINK} produces the expected values`,
},
};
runTestScenario(inputs, expected, routerComponent, {
tickDuration: 3,
waitForFinishDelay: 10,
analyzeTestResults: analyzeTestResults(assert, done),
errorHandler: function (err) {
done(err)
}
});
});
// C. with two nesting to test (TODO)
// /guru -> /guru:guruparams/master:masterparams ->
// /guru:guruparams/master:masterparams/detail:detailparams ->
// /guru:guruparams/master:masterparams -> /guru
// D. non-repetition of computation (nesting level of two)
// - /guru -> /guru -> /guru/master/detail -> /guru/master/detail -> /guru/master -> /guru/master