@cydran/testsupport 0.5.1 → 0.6.0
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 +1 -1
- package/dist/testsupport.d.ts +118 -40
- package/dist/testsupport.js +290 -273
- package/dist/testsupport.js.map +4 -4
- package/dist/testsupport.min.js +66 -0
- package/dist/testsupport.min.js.map +7 -0
- package/dist/testsupport.min.mjs +33 -0
- package/dist/testsupport.min.mjs.map +7 -0
- package/dist/testsupport.mjs +261 -0
- package/dist/testsupport.mjs.map +7 -0
- package/package.json +44 -19
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2018-2026 The Cydran Team <https://cydran.io/>
|
|
4
4
|
|
|
5
5
|
Derivative work based on Lodash 4.17.15 <https://lodash.com/license>
|
|
6
6
|
Copyright (c) 2019 OpenJS Foundation and other contributors <https://openjsf.org/>
|
package/dist/testsupport.d.ts
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
0.6.0
|
|
3
|
+
---
|
|
4
|
+
Cydran <https://cydran.io/>
|
|
5
|
+
Copyright (c) 2018-2026 The Cydran Team <https://cydran.io/>
|
|
6
|
+
SPDX-License-Identifier: MIT
|
|
7
|
+
---
|
|
8
|
+
Derivative work based on Lodash 4.17.15 <https://lodash.com/license>
|
|
9
|
+
Copyright (c) 2019 OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
10
|
+
---
|
|
11
|
+
Derivative work based on Underscore.js
|
|
12
|
+
Copyright (c) 2012 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
13
|
+
---
|
|
14
|
+
Derivative work based on docReady <https://github.com/jfriend00/docReady/blob/master/license>
|
|
15
|
+
Copyright (c) 2014, John Friend <https://github.com/jfriend00/docReady/>
|
|
16
|
+
---
|
|
17
|
+
Derivative work based on Math.uuid.js <http://www.broofa.com>
|
|
18
|
+
Copyright (c) 2010 Robert Kieffer <https://www.broofa.com/2008/09/javascript-uuid-function/>
|
|
19
|
+
---
|
|
20
|
+
Derivative work based on UMD <https://github.com/umdjs/umd/blob/master/LICENSE.md>
|
|
21
|
+
Copyright (c) 2014 the UMD contributors <https://github.com/umdjs/umd/>
|
|
2
22
|
|
|
23
|
+
*/
|
|
3
24
|
import { Matchers } from 'expect';
|
|
4
25
|
|
|
5
26
|
declare enum To {
|
|
@@ -82,7 +103,7 @@ export interface ActionContinuation extends Tellable, Messagable {
|
|
|
82
103
|
evaluate<T>(expression: string): T;
|
|
83
104
|
getParent(): Nestable;
|
|
84
105
|
getEl(): HTMLElement;
|
|
85
|
-
getObject<T>(id: string, ...instanceArguments:
|
|
106
|
+
getObject<T>(id: string, ...instanceArguments: InstanceArgument[]): T;
|
|
86
107
|
getLogger(): Logger;
|
|
87
108
|
properties(): Properties;
|
|
88
109
|
getId(): string;
|
|
@@ -92,7 +113,7 @@ export interface ActionContinuation extends Tellable, Messagable {
|
|
|
92
113
|
getValue<T>(): T;
|
|
93
114
|
isMounted(): boolean;
|
|
94
115
|
isConnected(): boolean;
|
|
95
|
-
send(messageName: string, payload?:
|
|
116
|
+
send(messageName: string, payload?: MessagePayload): SendContinuation;
|
|
96
117
|
onInterval(millis?: number): IntervalContinuation;
|
|
97
118
|
onMessage(messageName: string): OnContinuation;
|
|
98
119
|
/**
|
|
@@ -102,7 +123,7 @@ export interface ActionContinuation extends Tellable, Messagable {
|
|
|
102
123
|
*/
|
|
103
124
|
createFilter(expression: string): FilterBuilder;
|
|
104
125
|
regions(): RegionContinuation;
|
|
105
|
-
tell(name: string, payload?:
|
|
126
|
+
tell(name: string, payload?: MessagePayload): void;
|
|
106
127
|
forElement<E extends HTMLElement>(name: string): ElementOperations<E>;
|
|
107
128
|
forSeries(name: string): SeriesOperations;
|
|
108
129
|
forForm(name: string): FormOperations;
|
|
@@ -120,7 +141,7 @@ export interface Actionable<T> {
|
|
|
120
141
|
$c(): T;
|
|
121
142
|
}
|
|
122
143
|
export interface ArgumentsResolvers {
|
|
123
|
-
resolve(context: unknown, instanceArguments:
|
|
144
|
+
resolve(context: unknown, instanceArguments: InstanceArgument[]): ConstructorArgument[];
|
|
124
145
|
postProcess(context: unknown, targetObject: unknown, params: unknown[]): void;
|
|
125
146
|
}
|
|
126
147
|
export interface ComponentOptions {
|
|
@@ -134,13 +155,24 @@ export interface Context extends Sendable, Register<Context>, Tellable, Receivab
|
|
|
134
155
|
hasChild(name: string): boolean;
|
|
135
156
|
addChild(name: string, initializer?: (context: Context) => void): Context;
|
|
136
157
|
removeChild(name: string): Context;
|
|
137
|
-
getObject<T>(id: string, ...instanceArguments:
|
|
158
|
+
getObject<T>(id: string, ...instanceArguments: InstanceArgument[]): T;
|
|
138
159
|
getProperties(): MutableProperties;
|
|
139
160
|
getScope(): Scope;
|
|
140
161
|
getRoot(): Context;
|
|
141
162
|
isRoot(): boolean;
|
|
142
163
|
getParent(): Context;
|
|
143
164
|
registerImplicit(id: string, template: string, options?: ComponentOptions): Context;
|
|
165
|
+
/**
|
|
166
|
+
* Promotes this context's own object registration to its parent context, as an alias that resolves in this context.
|
|
167
|
+
* The alias is removed from the parent when this context is removed or released.
|
|
168
|
+
*
|
|
169
|
+
* @param id - the id of this context's own registration to promote
|
|
170
|
+
* @param overrideId - optional id to register the alias under in the parent, instead of id
|
|
171
|
+
* @returns this context
|
|
172
|
+
* @throws RegistrationError when this context has no registration of its own under id, or the parent already has one under the target id
|
|
173
|
+
* @throws UnsupportedOperationError when called on a root context or the global context
|
|
174
|
+
*/
|
|
175
|
+
promote(id: string, overrideId?: string): Context;
|
|
144
176
|
getName(): string;
|
|
145
177
|
getFullName(): string;
|
|
146
178
|
addPreInitializer(thisObject: CallBackThisObject, callback: (context?: Context) => void): void;
|
|
@@ -169,7 +201,7 @@ export interface Filter {
|
|
|
169
201
|
* Get the resulting array of items after the filter has been applied
|
|
170
202
|
* @returns array of filtered objects
|
|
171
203
|
*/
|
|
172
|
-
items():
|
|
204
|
+
items(): ListItem[];
|
|
173
205
|
/**
|
|
174
206
|
* Extend a {Filter filter} instance
|
|
175
207
|
* @returns a {FilterBuilder} object
|
|
@@ -178,8 +210,8 @@ export interface Filter {
|
|
|
178
210
|
}
|
|
179
211
|
export interface FilterBuilder {
|
|
180
212
|
withPredicate(expression: string, ...parameterExpressions: string[]): FilterBuilder;
|
|
181
|
-
withPhase(fn: (input:
|
|
182
|
-
withSimplePredicate(predicate: (index: number, value:
|
|
213
|
+
withPhase(fn: (input: ListItem[]) => ListItem[]): FilterBuilder;
|
|
214
|
+
withSimplePredicate(predicate: (index: number, value: ListItem) => boolean): FilterBuilder;
|
|
183
215
|
withSort(expression: string, ...parameterExpressions: string[]): FilterBuilder;
|
|
184
216
|
withLimit(limit: number): FilterBuilder;
|
|
185
217
|
with(fn: (builder: FilterBuilder) => void): FilterBuilder;
|
|
@@ -253,76 +285,76 @@ export interface Logger extends IsLevelType {
|
|
|
253
285
|
* @param primaryMsg to be written out
|
|
254
286
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
255
287
|
*/
|
|
256
|
-
trace(primaryMsg: string, ...moreArgs:
|
|
288
|
+
trace(primaryMsg: string, ...moreArgs: LogArgument[]): void;
|
|
257
289
|
/**
|
|
258
290
|
* Log payload at a "debug" level
|
|
259
291
|
* @param primaryMsg to be written out
|
|
260
292
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
261
293
|
*/
|
|
262
|
-
debug(primaryMsg: string, ...moreArgs:
|
|
294
|
+
debug(primaryMsg: string, ...moreArgs: LogArgument[]): void;
|
|
263
295
|
/**
|
|
264
296
|
* Log payload at a "info" level
|
|
265
297
|
* @param primaryMsg to be written out
|
|
266
298
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
267
299
|
*/
|
|
268
|
-
info(primaryMsg: string, ...moreArgs:
|
|
300
|
+
info(primaryMsg: string, ...moreArgs: LogArgument[]): void;
|
|
269
301
|
/**
|
|
270
302
|
* Log payload at a "warn" level
|
|
271
303
|
* @param primaryMsg to be written out
|
|
272
304
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
273
305
|
*/
|
|
274
|
-
warn(primaryMsg: string, ...moreArgs:
|
|
306
|
+
warn(primaryMsg: string, ...moreArgs: LogArgument[]): void;
|
|
275
307
|
/**
|
|
276
308
|
* Log payload at a "error" level
|
|
277
309
|
* @param primaryMsg to be written out
|
|
278
310
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
279
311
|
*/
|
|
280
|
-
error(primaryMsg: string, ...moreArgs:
|
|
312
|
+
error(primaryMsg: string, ...moreArgs: LogArgument[]): void;
|
|
281
313
|
/**
|
|
282
314
|
* Log payload at a "fatal" level
|
|
283
315
|
* @param primaryMsg to be written out
|
|
284
316
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
285
317
|
*/
|
|
286
|
-
fatal(primaryMsg: string, ...moreArgs:
|
|
318
|
+
fatal(primaryMsg: string, ...moreArgs: LogArgument[]): void;
|
|
287
319
|
/**
|
|
288
320
|
* Only if log at a "trace" level execute fn() to derive payload to log
|
|
289
321
|
* @param primaryMsgFn result of to be written out
|
|
290
322
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
291
323
|
*/
|
|
292
|
-
ifTrace(primaryMsgFn: () =>
|
|
324
|
+
ifTrace(primaryMsgFn: () => LogArgument, ...moreArgs: LogArgument[]): void;
|
|
293
325
|
/**
|
|
294
326
|
* Only if log at a "debug" level execute fn() to derive payload to log
|
|
295
327
|
* @param primaryMsgFn result of to be written out
|
|
296
328
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
297
329
|
*/
|
|
298
|
-
ifDebug(primaryMsgFn: () =>
|
|
330
|
+
ifDebug(primaryMsgFn: () => LogArgument, ...moreArgs: LogArgument[]): void;
|
|
299
331
|
/**
|
|
300
332
|
* Only if log at a "info" level execute fn() to derive payload to log
|
|
301
333
|
* @param primaryMsgFn result of to be written out
|
|
302
334
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
303
335
|
*/
|
|
304
|
-
ifInfo(primaryMsgFn: () =>
|
|
336
|
+
ifInfo(primaryMsgFn: () => LogArgument, ...moreArgs: LogArgument[]): void;
|
|
305
337
|
/**
|
|
306
338
|
* Only if log at a "warn" level execute fn() to derive payload to log
|
|
307
339
|
* @param primaryMsgFn result of to be written out
|
|
308
340
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
309
341
|
*/
|
|
310
|
-
ifWarn(primaryMsgFn: () =>
|
|
342
|
+
ifWarn(primaryMsgFn: () => LogArgument, ...moreArgs: LogArgument[]): void;
|
|
311
343
|
/**
|
|
312
344
|
* Only if log at a "error" level execute fn() to derive payload to log
|
|
313
345
|
* @param primaryMsgFn result of to be written out
|
|
314
346
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
315
347
|
*/
|
|
316
|
-
ifError(primaryMsgFn: () =>
|
|
348
|
+
ifError(primaryMsgFn: () => LogArgument, ...moreArgs: LogArgument[]): void;
|
|
317
349
|
/**
|
|
318
350
|
* Only if log at a "fatal" level execute fn() to derive payload to log
|
|
319
351
|
* @param primaryMsgFn result of to be written out
|
|
320
352
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
321
353
|
*/
|
|
322
|
-
ifFatal(primaryMsgFn: () =>
|
|
354
|
+
ifFatal(primaryMsgFn: () => LogArgument, ...moreArgs: LogArgument[]): void;
|
|
323
355
|
}
|
|
324
356
|
export interface Messagable {
|
|
325
|
-
send(messageName: string, payload?:
|
|
357
|
+
send(messageName: string, payload?: MessagePayload): SendContinuation;
|
|
326
358
|
}
|
|
327
359
|
export interface MetadataContinuation {
|
|
328
360
|
has: (name: string) => boolean;
|
|
@@ -335,13 +367,13 @@ export interface MutableProperties extends Properties {
|
|
|
335
367
|
* @param value - any type of object
|
|
336
368
|
* @returns
|
|
337
369
|
*/
|
|
338
|
-
set(key: string, value:
|
|
370
|
+
set(key: string, value: PropertyValue): MutableProperties;
|
|
339
371
|
/**
|
|
340
372
|
* Load additional properties in
|
|
341
373
|
* @param values - any type of object
|
|
342
374
|
* @returns
|
|
343
375
|
*/
|
|
344
|
-
load(values: SimpleMap<
|
|
376
|
+
load(values: SimpleMap<PropertyValue>): MutableProperties;
|
|
345
377
|
/**
|
|
346
378
|
* Remove a specific property by key
|
|
347
379
|
* @param key - string value
|
|
@@ -531,7 +563,7 @@ export interface Receivable {
|
|
|
531
563
|
* @param messageName The name of the message to send.
|
|
532
564
|
* @param payload The optional payload to include with the message.
|
|
533
565
|
*/
|
|
534
|
-
message(channelName: string, messageName: string, payload?:
|
|
566
|
+
message(channelName: string, messageName: string, payload?: MessagePayload): void;
|
|
535
567
|
}
|
|
536
568
|
export interface RegionContinuation {
|
|
537
569
|
/**
|
|
@@ -540,17 +572,17 @@ export interface RegionContinuation {
|
|
|
540
572
|
*/
|
|
541
573
|
has(name: string): boolean;
|
|
542
574
|
/**
|
|
543
|
-
* Get
|
|
544
|
-
* @param name - string name value of the
|
|
545
|
-
* @returns Component
|
|
575
|
+
* Get the child component in a region.
|
|
576
|
+
* @param name - string name value of the region
|
|
577
|
+
* @returns the {@link Component} in the region, or null when the region holds no component
|
|
546
578
|
*/
|
|
547
|
-
get<N extends Nestable>(name: string): N;
|
|
579
|
+
get<N extends Nestable>(name: string): N | null;
|
|
548
580
|
/**
|
|
549
|
-
* Set a child component into a region.
|
|
550
|
-
* @param name - string name value of the
|
|
551
|
-
* @param component - the {@link Component} reference
|
|
581
|
+
* Set a child component into a region, or clear the region.
|
|
582
|
+
* @param name - string name value of the region
|
|
583
|
+
* @param component - the {@link Component} reference, or null to remove the region's component and leave it empty
|
|
552
584
|
*/
|
|
553
|
-
set(name: string, component: Nestable): void;
|
|
585
|
+
set(name: string, component: Nestable | null): void;
|
|
554
586
|
setByObjectId(name: string, componentName: string, defaultComponentName?: string): void;
|
|
555
587
|
}
|
|
556
588
|
export interface Register<R> extends Releasable {
|
|
@@ -560,13 +592,12 @@ export interface Register<R> extends Releasable {
|
|
|
560
592
|
registerSingleton<T>(id: string, classInstance: Type<T>, resolvers?: ArgumentsResolvers, localResolution?: boolean): R;
|
|
561
593
|
registerSingletonWithFactory<T>(id: string, factoryFn: () => T, resolvers?: ArgumentsResolvers, localResolution?: boolean): R;
|
|
562
594
|
hasRegistration(id: string): boolean;
|
|
563
|
-
expose(id: string): R;
|
|
564
595
|
}
|
|
565
596
|
export interface Releasable {
|
|
566
597
|
$release(): void;
|
|
567
598
|
}
|
|
568
599
|
export interface Scope {
|
|
569
|
-
add(name: string, item:
|
|
600
|
+
add(name: string, item: ScopeItem): Scope;
|
|
570
601
|
remove(name: string): Scope;
|
|
571
602
|
extend(): Scope;
|
|
572
603
|
}
|
|
@@ -585,7 +616,7 @@ export interface Sendable {
|
|
|
585
616
|
* @param payload The optional payload to include with the message
|
|
586
617
|
* @param startFrom The optional path to the context start the traversal from
|
|
587
618
|
*/
|
|
588
|
-
send(propagation: To, channelName: string, messageName: string, payload?:
|
|
619
|
+
send(propagation: To, channelName: string, messageName: string, payload?: MessagePayload, startFrom?: string): void;
|
|
589
620
|
}
|
|
590
621
|
export interface SeriesOperations {
|
|
591
622
|
getAt<N extends Nestable>(index: number): N;
|
|
@@ -607,20 +638,67 @@ export interface Stage extends Releasable {
|
|
|
607
638
|
before(): SeriesOperations;
|
|
608
639
|
after(): SeriesOperations;
|
|
609
640
|
start(): Stage;
|
|
610
|
-
|
|
641
|
+
/**
|
|
642
|
+
* Set the top-level component of the stage, or remove it.
|
|
643
|
+
* @param component - the {@link Component} to place, or null to remove the current component and leave the stage empty
|
|
644
|
+
* @returns the stage
|
|
645
|
+
*/
|
|
646
|
+
setComponent(component: Nestable | null): Stage;
|
|
611
647
|
setComponentByObjectId(componentName: string, defaultComponentName?: string): Stage;
|
|
612
648
|
isStarted(): boolean;
|
|
613
649
|
addInitializer(thisObject: CallBackThisObject, callback: (stage: Stage) => void): Stage;
|
|
614
650
|
}
|
|
615
651
|
export interface Tellable {
|
|
616
|
-
tell(name: string, payload?:
|
|
652
|
+
tell(name: string, payload?: MessagePayload): void;
|
|
617
653
|
}
|
|
618
654
|
export interface WatchContinuation {
|
|
619
|
-
reducedBy<T>(reducerFn: (input:
|
|
655
|
+
reducedBy<T>(reducerFn: (input: ModelValue) => T): WatchContinuation;
|
|
620
656
|
invoke(name: string): void;
|
|
621
657
|
}
|
|
622
658
|
export type CallBackThisObject = object;
|
|
623
|
-
|
|
659
|
+
/**
|
|
660
|
+
* A resolved argument that is passed to the constructor or factory function that creates a registered object. It is
|
|
661
|
+
* `unknown`: any value is accepted, and a value must be narrowed before use. The name documents intent only, so compiler
|
|
662
|
+
* errors report it as `unknown`.
|
|
663
|
+
*/
|
|
664
|
+
export type ConstructorArgument = unknown;
|
|
665
|
+
/**
|
|
666
|
+
* An extra argument a caller passes when resolving an object by id, as in `getObject(id, ...instanceArguments)`. It is
|
|
667
|
+
* `unknown`: any value is accepted, and a value must be narrowed before use. The name documents intent only, so compiler
|
|
668
|
+
* errors report it as `unknown`.
|
|
669
|
+
*/
|
|
670
|
+
export type InstanceArgument = unknown;
|
|
671
|
+
/**
|
|
672
|
+
* An element of an array rendered by `c-each` or processed by a filter. It is `unknown`: any value is accepted, and a
|
|
673
|
+
* value must be narrowed before use. The name documents intent only, so compiler errors report it as `unknown`.
|
|
674
|
+
*/
|
|
675
|
+
export type ListItem = unknown;
|
|
676
|
+
/**
|
|
677
|
+
* A value passed to a logger method, after or in place of the primary message. It is `unknown`: any value is accepted, and
|
|
678
|
+
* a value must be narrowed before use. The name documents intent only, so compiler errors report it as `unknown`.
|
|
679
|
+
*/
|
|
680
|
+
export type LogArgument = unknown;
|
|
681
|
+
export type MessageCallback = (channelName: string, messageName: string, payload: MessagePayload) => void;
|
|
682
|
+
/**
|
|
683
|
+
* The payload of a message that is sent, told, delivered or received. It is `unknown`: any value is accepted, and a value
|
|
684
|
+
* must be narrowed before use. The name documents intent only, so compiler errors report it as `unknown`.
|
|
685
|
+
*/
|
|
686
|
+
export type MessagePayload = unknown;
|
|
687
|
+
/**
|
|
688
|
+
* A value read from or written to the model through a template expression. It is `unknown`: any value is accepted, and a
|
|
689
|
+
* value must be narrowed before use. The name documents intent only, so compiler errors report it as `unknown`.
|
|
690
|
+
*/
|
|
691
|
+
export type ModelValue = unknown;
|
|
692
|
+
/**
|
|
693
|
+
* The value of a configuration property. It is `unknown`: any value is accepted, and a value must be narrowed before use.
|
|
694
|
+
* The name documents intent only, so compiler errors report it as `unknown`.
|
|
695
|
+
*/
|
|
696
|
+
export type PropertyValue = unknown;
|
|
697
|
+
/**
|
|
698
|
+
* A value added to a scope, and reachable from template expressions through `s()`. It is `unknown`: any value is accepted,
|
|
699
|
+
* and a value must be narrowed before use. The name documents intent only, so compiler errors report it as `unknown`.
|
|
700
|
+
*/
|
|
701
|
+
export type ScopeItem = unknown;
|
|
624
702
|
export type SimpleMap<T> = Record<string, T>;
|
|
625
703
|
export type Type<T> = new (...args: any[]) => T;
|
|
626
704
|
|