@cydran/testsupport 0.4.0 → 0.5.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/dist/testsupport.d.ts +88 -83
- package/dist/testsupport.js +11 -5
- package/dist/testsupport.js.map +2 -2
- package/package.json +5 -21
package/dist/testsupport.d.ts
CHANGED
|
@@ -19,6 +19,10 @@ declare enum To {
|
|
|
19
19
|
* Sends a message to all immediate children of the current context.
|
|
20
20
|
*/
|
|
21
21
|
IMMEDIATE_CHILDREN = "IMMEDIATE_CHILDREN",
|
|
22
|
+
/**
|
|
23
|
+
* Sends a message to all immediate child components of the current component.
|
|
24
|
+
*/
|
|
25
|
+
IMMEDIATE_CHILD_COMPONENTS = "IMMEDIATE_CHILD_COMPONENTS",
|
|
22
26
|
/**
|
|
23
27
|
* Sends a message to the parent of the current context.
|
|
24
28
|
*/
|
|
@@ -40,7 +44,7 @@ export declare class Harness<C extends Nestable> {
|
|
|
40
44
|
private actualProperties;
|
|
41
45
|
private initialProperties;
|
|
42
46
|
private root;
|
|
43
|
-
constructor(rootSupplier?: () => C, properties?:
|
|
47
|
+
constructor(rootSupplier?: () => C, properties?: SimpleMap<unknown>);
|
|
44
48
|
reset(): void;
|
|
45
49
|
start(): Harness<C>;
|
|
46
50
|
stop(): Harness<C>;
|
|
@@ -49,9 +53,12 @@ export declare class Harness<C extends Nestable> {
|
|
|
49
53
|
getDocument(): Document;
|
|
50
54
|
getContext(): Context;
|
|
51
55
|
getStage(): Stage;
|
|
52
|
-
registerConstant(id: string, instance:
|
|
53
|
-
registerPrototype(id: string, classInstance: Type<
|
|
54
|
-
registerSingleton(id: string, classInstance: Type<
|
|
56
|
+
registerConstant<T>(id: string, instance: T): void;
|
|
57
|
+
registerPrototype<T>(id: string, classInstance: Type<T>, resolvers?: ArgumentsResolvers): void;
|
|
58
|
+
registerSingleton<T>(id: string, classInstance: Type<T>, resolvers?: ArgumentsResolvers): void;
|
|
59
|
+
registerConstantGlobally<T>(id: string, instance: T): void;
|
|
60
|
+
registerPrototypeGlobally<T>(id: string, classInstance: Type<T>, resolvers?: ArgumentsResolvers): void;
|
|
61
|
+
registerSingletonGlobally<T>(id: string, classInstance: Type<T>, resolvers?: ArgumentsResolvers): void;
|
|
55
62
|
forRole(value: string): Operations;
|
|
56
63
|
forLabelText(value: string): Operations;
|
|
57
64
|
forPlaceholderText(value: string): Operations;
|
|
@@ -60,16 +67,16 @@ export declare class Harness<C extends Nestable> {
|
|
|
60
67
|
forAltText(value: string): Operations;
|
|
61
68
|
forTitle(value: string): Operations;
|
|
62
69
|
forTestId(value: string): Operations;
|
|
63
|
-
expectBody(): Matchers<
|
|
70
|
+
expectBody(): Matchers<void, string>;
|
|
64
71
|
}
|
|
65
|
-
export declare function isDefined(value:
|
|
66
|
-
export declare function merge<T>(sources:
|
|
67
|
-
export declare function overlay<T>(destination: T, sources:
|
|
72
|
+
export declare function isDefined<T>(value: T): boolean;
|
|
73
|
+
export declare function merge<T>(sources: unknown[]): T;
|
|
74
|
+
export declare function overlay<T>(destination: T, sources: unknown[]): T;
|
|
68
75
|
export declare function requireNotNull<T>(value: T, name: string): T;
|
|
69
76
|
export interface ActionContinuation extends Tellable, Messagable, Watchable {
|
|
70
77
|
getParent(): Nestable;
|
|
71
78
|
getEl(): HTMLElement;
|
|
72
|
-
getObject<T>(id: string, ...instanceArguments:
|
|
79
|
+
getObject<T>(id: string, ...instanceArguments: unknown[]): T;
|
|
73
80
|
getLogger(): Logger;
|
|
74
81
|
properties(): Properties;
|
|
75
82
|
getId(): string;
|
|
@@ -79,8 +86,8 @@ export interface ActionContinuation extends Tellable, Messagable, Watchable {
|
|
|
79
86
|
getValue<T>(): T;
|
|
80
87
|
isMounted(): boolean;
|
|
81
88
|
isConnected(): boolean;
|
|
82
|
-
send(messageName: string, payload?:
|
|
83
|
-
onInterval(millis?:
|
|
89
|
+
send(messageName: string, payload?: unknown): SendContinuation;
|
|
90
|
+
onInterval(millis?: number): IntervalContinuation;
|
|
84
91
|
onMessage(messageName: string): OnContinuation;
|
|
85
92
|
/**
|
|
86
93
|
* Get a {@linkcode FilterBuilder} object back to create a {@linkcode Filter} of lists in the model
|
|
@@ -89,7 +96,7 @@ export interface ActionContinuation extends Tellable, Messagable, Watchable {
|
|
|
89
96
|
*/
|
|
90
97
|
createFilter(expression: string): FilterBuilder;
|
|
91
98
|
regions(): RegionContinuation;
|
|
92
|
-
tell(name: string, payload?:
|
|
99
|
+
tell(name: string, payload?: unknown): void;
|
|
93
100
|
forElement<E extends HTMLElement>(name: string): ElementOperations<E>;
|
|
94
101
|
forSeries(name: string): SeriesOperations;
|
|
95
102
|
forForm(name: string): FormOperations;
|
|
@@ -107,20 +114,21 @@ export interface Actionable<T> {
|
|
|
107
114
|
$c(): T;
|
|
108
115
|
}
|
|
109
116
|
export interface ArgumentsResolvers {
|
|
110
|
-
resolve(context:
|
|
111
|
-
postProcess(context:
|
|
117
|
+
resolve(context: unknown, instanceArguments: unknown[]): unknown[];
|
|
118
|
+
postProcess(context: unknown, targetObject: unknown, params: unknown[]): void;
|
|
112
119
|
}
|
|
113
120
|
export interface ComponentOptions {
|
|
114
|
-
metadata?: SimpleMap<
|
|
121
|
+
metadata?: SimpleMap<unknown>;
|
|
115
122
|
prefix?: string;
|
|
116
123
|
styles?: string;
|
|
124
|
+
name?: string;
|
|
117
125
|
}
|
|
118
126
|
export interface Context extends Sendable, Register<Context>, Tellable, Receivable {
|
|
119
127
|
getChild(name: string): Context;
|
|
120
128
|
hasChild(name: string): boolean;
|
|
121
129
|
addChild(name: string, initializer?: (context: Context) => void): Context;
|
|
122
130
|
removeChild(name: string): Context;
|
|
123
|
-
getObject<T>(id: string, ...instanceArguments:
|
|
131
|
+
getObject<T>(id: string, ...instanceArguments: unknown[]): T;
|
|
124
132
|
getProperties(): MutableProperties;
|
|
125
133
|
getScope(): Scope;
|
|
126
134
|
getRoot(): Context;
|
|
@@ -129,12 +137,12 @@ export interface Context extends Sendable, Register<Context>, Tellable, Receivab
|
|
|
129
137
|
registerImplicit(id: string, template: string, options?: ComponentOptions): Context;
|
|
130
138
|
getName(): string;
|
|
131
139
|
getFullName(): string;
|
|
132
|
-
addPreInitializer(thisObject:
|
|
133
|
-
addInitializer(thisObject:
|
|
134
|
-
addDisposer(thisObject:
|
|
135
|
-
configure(callback: (context: Context) => void, thisObject?:
|
|
136
|
-
addListener(thisObject:
|
|
137
|
-
removeListener(thisObject:
|
|
140
|
+
addPreInitializer(thisObject: CallBackThisObject, callback: (context?: Context) => void): void;
|
|
141
|
+
addInitializer(thisObject: CallBackThisObject, callback: (context?: Context) => void): void;
|
|
142
|
+
addDisposer(thisObject: CallBackThisObject, callback: (context?: Context) => void): void;
|
|
143
|
+
configure(callback: (context: Context) => void, thisObject?: CallBackThisObject): Context;
|
|
144
|
+
addListener(thisObject: CallBackThisObject, callback: MessageCallback): void;
|
|
145
|
+
removeListener(thisObject: CallBackThisObject, callback: MessageCallback): void;
|
|
138
146
|
}
|
|
139
147
|
export interface DestinationContinuation {
|
|
140
148
|
withPropagation(propagation: To): void;
|
|
@@ -146,16 +154,16 @@ export interface ElementOperations<E extends HTMLElement> {
|
|
|
146
154
|
blur(): void;
|
|
147
155
|
}
|
|
148
156
|
export interface ExpectionActions {
|
|
149
|
-
selectedValues(): Matchers<
|
|
150
|
-
trimmedTextContent(): Matchers<
|
|
151
|
-
textContent(): Matchers<
|
|
157
|
+
selectedValues(): Matchers<void, string[]>;
|
|
158
|
+
trimmedTextContent(): Matchers<void, string>;
|
|
159
|
+
textContent(): Matchers<void, string>;
|
|
152
160
|
}
|
|
153
161
|
export interface Filter {
|
|
154
162
|
/**
|
|
155
163
|
* Get the resulting array of items after the filter has been applied
|
|
156
164
|
* @returns array of filtered objects
|
|
157
165
|
*/
|
|
158
|
-
items():
|
|
166
|
+
items(): unknown[];
|
|
159
167
|
/**
|
|
160
168
|
* Extend a {Filter filter} instance
|
|
161
169
|
* @returns a {FilterBuilder} object
|
|
@@ -164,8 +172,8 @@ export interface Filter {
|
|
|
164
172
|
}
|
|
165
173
|
export interface FilterBuilder {
|
|
166
174
|
withPredicate(expression: string, ...parameterExpressions: string[]): FilterBuilder;
|
|
167
|
-
withPhase(fn: (input:
|
|
168
|
-
withSimplePredicate(predicate: (index: number, value:
|
|
175
|
+
withPhase(fn: (input: unknown[]) => unknown[]): FilterBuilder;
|
|
176
|
+
withSimplePredicate(predicate: (index: number, value: unknown) => boolean): FilterBuilder;
|
|
169
177
|
withSort(expression: string, ...parameterExpressions: string[]): FilterBuilder;
|
|
170
178
|
withLimit(limit: number): FilterBuilder;
|
|
171
179
|
with(fn: (builder: FilterBuilder) => void): FilterBuilder;
|
|
@@ -174,7 +182,7 @@ export interface FilterBuilder {
|
|
|
174
182
|
limited(): LimitOffsetFilter;
|
|
175
183
|
}
|
|
176
184
|
export interface ForChannelContinuation {
|
|
177
|
-
invoke(callback: (payload:
|
|
185
|
+
invoke(callback: (payload: unknown) => void): void;
|
|
178
186
|
}
|
|
179
187
|
export interface FormOperations {
|
|
180
188
|
submit(): void;
|
|
@@ -239,80 +247,80 @@ export interface Logger extends IsLevelType {
|
|
|
239
247
|
* @param primaryMsg to be written out
|
|
240
248
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
241
249
|
*/
|
|
242
|
-
trace(primaryMsg: string, ...moreArgs:
|
|
250
|
+
trace(primaryMsg: string, ...moreArgs: unknown[]): void;
|
|
243
251
|
/**
|
|
244
252
|
* Log payload at a "debug" level
|
|
245
253
|
* @param primaryMsg to be written out
|
|
246
254
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
247
255
|
*/
|
|
248
|
-
debug(primaryMsg: string, ...moreArgs:
|
|
256
|
+
debug(primaryMsg: string, ...moreArgs: unknown[]): void;
|
|
249
257
|
/**
|
|
250
258
|
* Log payload at a "info" level
|
|
251
259
|
* @param primaryMsg to be written out
|
|
252
260
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
253
261
|
*/
|
|
254
|
-
info(primaryMsg: string, ...moreArgs:
|
|
262
|
+
info(primaryMsg: string, ...moreArgs: unknown[]): void;
|
|
255
263
|
/**
|
|
256
264
|
* Log payload at a "warn" level
|
|
257
265
|
* @param primaryMsg to be written out
|
|
258
266
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
259
267
|
*/
|
|
260
|
-
warn(primaryMsg: string, ...moreArgs:
|
|
268
|
+
warn(primaryMsg: string, ...moreArgs: unknown[]): void;
|
|
261
269
|
/**
|
|
262
270
|
* Log payload at a "error" level
|
|
263
271
|
* @param primaryMsg to be written out
|
|
264
272
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
265
273
|
*/
|
|
266
|
-
error(primaryMsg: string, ...moreArgs:
|
|
274
|
+
error(primaryMsg: string, ...moreArgs: unknown[]): void;
|
|
267
275
|
/**
|
|
268
276
|
* Log payload at a "fatal" level
|
|
269
277
|
* @param primaryMsg to be written out
|
|
270
278
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
271
279
|
*/
|
|
272
|
-
fatal(primaryMsg: string, ...moreArgs:
|
|
280
|
+
fatal(primaryMsg: string, ...moreArgs: unknown[]): void;
|
|
273
281
|
/**
|
|
274
282
|
* Only if log at a "trace" level execute fn() to derive payload to log
|
|
275
283
|
* @param primaryMsgFn result of to be written out
|
|
276
284
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
277
285
|
*/
|
|
278
|
-
ifTrace(primaryMsgFn: () =>
|
|
286
|
+
ifTrace(primaryMsgFn: () => unknown, ...moreArgs: unknown[]): void;
|
|
279
287
|
/**
|
|
280
288
|
* Only if log at a "debug" level execute fn() to derive payload to log
|
|
281
289
|
* @param primaryMsgFn result of to be written out
|
|
282
290
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
283
291
|
*/
|
|
284
|
-
ifDebug(primaryMsgFn: () =>
|
|
292
|
+
ifDebug(primaryMsgFn: () => unknown, ...moreArgs: unknown[]): void;
|
|
285
293
|
/**
|
|
286
294
|
* Only if log at a "info" level execute fn() to derive payload to log
|
|
287
295
|
* @param primaryMsgFn result of to be written out
|
|
288
296
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
289
297
|
*/
|
|
290
|
-
ifInfo(primaryMsgFn: () =>
|
|
298
|
+
ifInfo(primaryMsgFn: () => unknown, ...moreArgs: unknown[]): void;
|
|
291
299
|
/**
|
|
292
300
|
* Only if log at a "warn" level execute fn() to derive payload to log
|
|
293
301
|
* @param primaryMsgFn result of to be written out
|
|
294
302
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
295
303
|
*/
|
|
296
|
-
ifWarn(primaryMsgFn: () =>
|
|
304
|
+
ifWarn(primaryMsgFn: () => unknown, ...moreArgs: unknown[]): void;
|
|
297
305
|
/**
|
|
298
306
|
* Only if log at a "error" level execute fn() to derive payload to log
|
|
299
307
|
* @param primaryMsgFn result of to be written out
|
|
300
308
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
301
309
|
*/
|
|
302
|
-
ifError(primaryMsgFn: () =>
|
|
310
|
+
ifError(primaryMsgFn: () => unknown, ...moreArgs: unknown[]): void;
|
|
303
311
|
/**
|
|
304
312
|
* Only if log at a "fatal" level execute fn() to derive payload to log
|
|
305
313
|
* @param primaryMsgFn result of to be written out
|
|
306
314
|
* @param moreArgs additional optional arguments; the last argument as an Error is assumed to be required for the stack ouptut regardless of log level
|
|
307
315
|
*/
|
|
308
|
-
ifFatal(primaryMsgFn: () =>
|
|
316
|
+
ifFatal(primaryMsgFn: () => unknown, ...moreArgs: unknown[]): void;
|
|
309
317
|
}
|
|
310
318
|
export interface Messagable {
|
|
311
|
-
send(messageName: string, payload?:
|
|
319
|
+
send(messageName: string, payload?: unknown): SendContinuation;
|
|
312
320
|
}
|
|
313
321
|
export interface MetadataContinuation {
|
|
314
322
|
has: (name: string) => boolean;
|
|
315
|
-
get: (name: string) =>
|
|
323
|
+
get: <T>(name: string) => T;
|
|
316
324
|
}
|
|
317
325
|
export interface MutableProperties extends Properties {
|
|
318
326
|
/**
|
|
@@ -321,13 +329,13 @@ export interface MutableProperties extends Properties {
|
|
|
321
329
|
* @param value - any type of object
|
|
322
330
|
* @returns
|
|
323
331
|
*/
|
|
324
|
-
set(key: string, value:
|
|
332
|
+
set(key: string, value: unknown): MutableProperties;
|
|
325
333
|
/**
|
|
326
334
|
* Load additional properties in
|
|
327
335
|
* @param values - any type of object
|
|
328
336
|
* @returns
|
|
329
337
|
*/
|
|
330
|
-
load(values:
|
|
338
|
+
load(values: SimpleMap<unknown>): MutableProperties;
|
|
331
339
|
/**
|
|
332
340
|
* Remove a specific property by key
|
|
333
341
|
* @param key - string value
|
|
@@ -373,22 +381,22 @@ export interface Nestable extends Actionable<ActionContinuation> {
|
|
|
373
381
|
onRemount(): void;
|
|
374
382
|
}
|
|
375
383
|
export interface OnContinuation {
|
|
376
|
-
invoke(callback: (payload:
|
|
384
|
+
invoke(callback: (payload: unknown) => void): void;
|
|
377
385
|
forChannel(channelName: string): ForChannelContinuation;
|
|
378
386
|
}
|
|
379
387
|
export interface Operations {
|
|
380
|
-
get<E extends HTMLElement>(options?:
|
|
381
|
-
query(options?:
|
|
382
|
-
find(options?:
|
|
383
|
-
getAll(options?:
|
|
384
|
-
queryAll(options?:
|
|
385
|
-
findAll(options?:
|
|
386
|
-
expect(options?:
|
|
387
|
-
appendText(text: string, options?:
|
|
388
|
-
replaceText(text: string, options?:
|
|
389
|
-
selectIndex(index: number, options?:
|
|
390
|
-
selectIndexes(indexes: number[], options?:
|
|
391
|
-
setCheckedState(options?:
|
|
388
|
+
get<E extends HTMLElement>(options?: unknown): E;
|
|
389
|
+
query(options?: unknown): HTMLElement;
|
|
390
|
+
find(options?: unknown): HTMLElement;
|
|
391
|
+
getAll(options?: unknown): HTMLElement[];
|
|
392
|
+
queryAll(options?: unknown): HTMLElement[];
|
|
393
|
+
findAll(options?: unknown): HTMLElement[];
|
|
394
|
+
expect(options?: unknown): ExpectionActions;
|
|
395
|
+
appendText(text: string, options?: unknown): void;
|
|
396
|
+
replaceText(text: string, options?: unknown): void;
|
|
397
|
+
selectIndex(index: number, options?: unknown): void;
|
|
398
|
+
selectIndexes(indexes: number[], options?: unknown): void;
|
|
399
|
+
setCheckedState(options?: unknown): void;
|
|
392
400
|
}
|
|
393
401
|
export interface PagedFilter extends Filter {
|
|
394
402
|
getPageSize(): number;
|
|
@@ -411,13 +419,13 @@ export interface Properties {
|
|
|
411
419
|
* @param thisObject Object used as this when calling the callback
|
|
412
420
|
* @param callback - callback function to be called when any property is changed
|
|
413
421
|
*/
|
|
414
|
-
addObserver(thisObject:
|
|
422
|
+
addObserver(thisObject: CallBackThisObject, callback: (key: string, value: unknown) => void): void;
|
|
415
423
|
/**
|
|
416
424
|
* Remove an observer that listened for all property changes.
|
|
417
425
|
* @param thisObject Object used as this when calling the callback
|
|
418
426
|
* @param callback callback function to be removed
|
|
419
427
|
*/
|
|
420
|
-
removeObserver(thisObject:
|
|
428
|
+
removeObserver(thisObject: CallBackThisObject, callback: (key: string, value: unknown) => void): void;
|
|
421
429
|
/**
|
|
422
430
|
* Add an observer for a specific property changes, or changes of more general property when the preferred is unavailable.
|
|
423
431
|
* @param thisObject Object used as this when calling the callback
|
|
@@ -425,27 +433,27 @@ export interface Properties {
|
|
|
425
433
|
* @param preferredKey Preferred property key to observe
|
|
426
434
|
* @param prefix Property key prefix for keys which should be included for consideration
|
|
427
435
|
*/
|
|
428
|
-
addFallbackObserver(thisObject:
|
|
436
|
+
addFallbackObserver(thisObject: CallBackThisObject, callback: (key: string, value: unknown) => void, preferredKey: string, prefix?: string): void;
|
|
429
437
|
/**
|
|
430
438
|
* Remove an observer for a specific property changes, or changes of more general property when the preferred is unavailable.
|
|
431
439
|
* @param thisObject Object used as this when calling the callback
|
|
432
440
|
* @param callback callback function to be removed
|
|
433
441
|
*/
|
|
434
|
-
removeFallbackObserver(thisObject:
|
|
442
|
+
removeFallbackObserver(thisObject: CallBackThisObject, callback: (key: string, value: unknown) => void): void;
|
|
435
443
|
/**
|
|
436
444
|
* Add an observer for specific property.
|
|
437
445
|
* @param key Specific property key
|
|
438
446
|
* @param thisObject Object used as this when calling the callback
|
|
439
447
|
* @param callback callback function to be called when the specific property is changed
|
|
440
448
|
*/
|
|
441
|
-
addPropertyObserver(key: string, thisObject:
|
|
449
|
+
addPropertyObserver(key: string, thisObject: CallBackThisObject, callback: (value: unknown) => void): void;
|
|
442
450
|
/**
|
|
443
451
|
* Remove an observer for specific property.
|
|
444
452
|
* @param key Specific property key
|
|
445
453
|
* @param thisObject Object used as this when calling the callback
|
|
446
454
|
* @param callback callback function to remove
|
|
447
455
|
*/
|
|
448
|
-
removePropertyObserver(key: string, thisObject:
|
|
456
|
+
removePropertyObserver(key: string, thisObject: CallBackThisObject, callback: (value: unknown) => void): void;
|
|
449
457
|
snapshot(): MutableProperties;
|
|
450
458
|
/**
|
|
451
459
|
* Get all the keys present in the properties object
|
|
@@ -517,7 +525,7 @@ export interface Receivable {
|
|
|
517
525
|
* @param messageName The name of the message to send.
|
|
518
526
|
* @param payload The optional payload to include with the message.
|
|
519
527
|
*/
|
|
520
|
-
message(channelName: string, messageName: string, payload?:
|
|
528
|
+
message(channelName: string, messageName: string, payload?: unknown): void;
|
|
521
529
|
}
|
|
522
530
|
export interface RegionContinuation {
|
|
523
531
|
/**
|
|
@@ -540,11 +548,11 @@ export interface RegionContinuation {
|
|
|
540
548
|
setByObjectId(name: string, componentName: string, defaultComponentName?: string): void;
|
|
541
549
|
}
|
|
542
550
|
export interface Register<R> extends Releasable {
|
|
543
|
-
registerConstant(id: string, instance:
|
|
544
|
-
registerPrototype(id: string, classInstance: Type<
|
|
545
|
-
registerPrototypeWithFactory(id: string, factoryFn: () =>
|
|
546
|
-
registerSingleton(id: string, classInstance: Type<
|
|
547
|
-
registerSingletonWithFactory(id: string, factoryFn: () =>
|
|
551
|
+
registerConstant<T>(id: string, instance: T): R;
|
|
552
|
+
registerPrototype<T>(id: string, classInstance: Type<T>, resolvers?: ArgumentsResolvers, localResolution?: boolean): R;
|
|
553
|
+
registerPrototypeWithFactory<T>(id: string, factoryFn: () => T, resolvers?: ArgumentsResolvers, localResolution?: boolean): R;
|
|
554
|
+
registerSingleton<T>(id: string, classInstance: Type<T>, resolvers?: ArgumentsResolvers, localResolution?: boolean): R;
|
|
555
|
+
registerSingletonWithFactory<T>(id: string, factoryFn: () => T, resolvers?: ArgumentsResolvers, localResolution?: boolean): R;
|
|
548
556
|
hasRegistration(id: string): boolean;
|
|
549
557
|
expose(id: string): R;
|
|
550
558
|
}
|
|
@@ -552,7 +560,7 @@ export interface Releasable {
|
|
|
552
560
|
$release(): void;
|
|
553
561
|
}
|
|
554
562
|
export interface Scope {
|
|
555
|
-
add(name: string, item:
|
|
563
|
+
add(name: string, item: unknown): Scope;
|
|
556
564
|
remove(name: string): Scope;
|
|
557
565
|
extend(): Scope;
|
|
558
566
|
}
|
|
@@ -571,7 +579,7 @@ export interface Sendable {
|
|
|
571
579
|
* @param payload The optional payload to include with the message
|
|
572
580
|
* @param startFrom The optional path to the context start the traversal from
|
|
573
581
|
*/
|
|
574
|
-
send(propagation: To, channelName: string, messageName: string, payload?:
|
|
582
|
+
send(propagation: To, channelName: string, messageName: string, payload?: unknown, startFrom?: string): void;
|
|
575
583
|
}
|
|
576
584
|
export interface SeriesOperations {
|
|
577
585
|
getAt<N extends Nestable>(index: number): N;
|
|
@@ -588,9 +596,6 @@ export interface SeriesOperations {
|
|
|
588
596
|
isEmpty(): boolean;
|
|
589
597
|
clear(): void;
|
|
590
598
|
}
|
|
591
|
-
export interface SimpleMap<T> {
|
|
592
|
-
[key: string]: T;
|
|
593
|
-
}
|
|
594
599
|
export interface Stage extends Releasable {
|
|
595
600
|
getContext(): Context;
|
|
596
601
|
before(): SeriesOperations;
|
|
@@ -599,24 +604,24 @@ export interface Stage extends Releasable {
|
|
|
599
604
|
setComponent(component: Nestable): Stage;
|
|
600
605
|
setComponentByObjectId(componentName: string, defaultComponentName?: string): Stage;
|
|
601
606
|
isStarted(): boolean;
|
|
602
|
-
addInitializer(thisObject:
|
|
607
|
+
addInitializer(thisObject: CallBackThisObject, callback: (stage: Stage) => void): Stage;
|
|
603
608
|
}
|
|
604
609
|
export interface Tellable {
|
|
605
|
-
tell(name: string, payload?:
|
|
606
|
-
}
|
|
607
|
-
export interface Type<T> extends Function {
|
|
608
|
-
new (...args: any[]): T;
|
|
610
|
+
tell(name: string, payload?: unknown): void;
|
|
609
611
|
}
|
|
610
612
|
export interface Watchable {
|
|
611
|
-
onExpressionValueChange<T>(expression: string, callback: (previous: T, current: T) => void, reducerFn?: (input:
|
|
613
|
+
onExpressionValueChange<T>(expression: string, callback: (previous: T, current: T) => void, reducerFn?: (input: unknown) => T, thisObject?: CallBackThisObject): void;
|
|
612
614
|
/**
|
|
613
615
|
* Evaluates an expression.
|
|
614
616
|
* @param expression Expression to evaluate.
|
|
615
617
|
*/
|
|
616
618
|
evaluate<T>(expression: string): T;
|
|
617
|
-
getWatchScope():
|
|
619
|
+
getWatchScope(): unknown;
|
|
618
620
|
}
|
|
619
|
-
export type
|
|
621
|
+
export type CallBackThisObject = object;
|
|
622
|
+
export type MessageCallback = (channelName: string, messageName: string, payload: unknown) => void;
|
|
623
|
+
export type SimpleMap<T> = Record<string, T>;
|
|
624
|
+
export type Type<T> = new (...args: any[]) => T;
|
|
620
625
|
|
|
621
626
|
export as namespace testsupport;
|
|
622
627
|
|
package/dist/testsupport.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
0.
|
|
2
|
+
0.5.0
|
|
3
3
|
---
|
|
4
4
|
Cydran <http://cydran.io/>
|
|
5
5
|
Copyright (c) 2018 The Cydran Team and other contributors <http://cydran.io/>
|
|
@@ -199,6 +199,15 @@ var testsupport = (() => {
|
|
|
199
199
|
registerSingleton(id, classInstance, resolvers) {
|
|
200
200
|
this.stage.getContext().registerSingleton(id, classInstance, resolvers);
|
|
201
201
|
}
|
|
202
|
+
registerConstantGlobally(id, instance) {
|
|
203
|
+
this.stage.getContext()["obscuredParent"].registerConstant(id, instance);
|
|
204
|
+
}
|
|
205
|
+
registerPrototypeGlobally(id, classInstance, resolvers) {
|
|
206
|
+
this.stage.getContext()["obscuredParent"].registerPrototype(id, classInstance, resolvers);
|
|
207
|
+
}
|
|
208
|
+
registerSingletonGlobally(id, classInstance, resolvers) {
|
|
209
|
+
this.stage.getContext()["obscuredParent"].registerSingleton(id, classInstance, resolvers);
|
|
210
|
+
}
|
|
202
211
|
forRole(value) {
|
|
203
212
|
return new OperationsImpl(this.document.documentElement, value, "Role");
|
|
204
213
|
}
|
|
@@ -265,10 +274,7 @@ var testsupport = (() => {
|
|
|
265
274
|
if (!isDefined(source)) {
|
|
266
275
|
continue;
|
|
267
276
|
}
|
|
268
|
-
for (const name
|
|
269
|
-
if (!source.hasOwnProperty(name)) {
|
|
270
|
-
continue;
|
|
271
|
-
}
|
|
277
|
+
for (const name of Object.keys(source)) {
|
|
272
278
|
if (!isDefined(source[name])) {
|
|
273
279
|
continue;
|
|
274
280
|
}
|
package/dist/testsupport.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/harness/Harness.ts", "../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { JSDOM } from 'jsdom';\nimport { Nestable, requireNotNull, isDefined, Stage, Context, Type, merge, ArgumentsResolvers, PropertyKeys, Component, create } from \"@cydran/cydran\";\nimport { queries, fireEvent } from '@testing-library/dom';\nimport { expect } from '@jest/globals';\nimport { Matchers } from 'expect';\n\nclass TestComponent extends Component {\n\t\n\tconstructor() {\n\t\tsuper(\"<div></div>\");\n\t}\n\n}\n\nconst DEFAULT_COMPONENT_SUPPLIER: () => any = () => new TestComponent();\n\nconst HTML: string = `<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<title>Cydran Test Harness</title>\n\t</head>\n\t<body>\n\t\t<!-- Stage Content -->\n\t</body>\n</html>`;\n\ninterface ExpectionActions {\n\n\tselectedValues(): Matchers<any>;\n\n\ttrimmedTextContent(): Matchers<any>;\n\n\ttextContent(): Matchers<any>;\n\n}\n\ninterface Operations {\n\n\tget<E extends HTMLElement>(options?: any): E;\n\n\tquery(options?: any): HTMLElement;\n\n\tfind(options?: any): HTMLElement;\n\n\tgetAll(options?: any): HTMLElement[];\n\n\tqueryAll(options?: any): HTMLElement[];\n\n\tfindAll(options?: any): HTMLElement[];\n\n\texpect(options?: any): ExpectionActions;\n\n\tappendText(text: string, options?: any): void;\n\n\treplaceText(text: string, options?: any): void;\n\n\tselectIndex(index: number, options?: any): void;\n\n\tselectIndexes(indexes: number[], options?: any): void;\n\n\tsetCheckedState(options?: any): void;\n\n}\n\nclass ExpectionActionsImpl implements ExpectionActions {\n\n\tprivate element: HTMLElement;\n\n\tconstructor(element: HTMLElement) {\n\t\tthis.element = requireNotNull(element, \"element\");\n\t}\n\n\tpublic selectedValues(): Matchers<any> {\n\t\tconst selected: string[] = [];\n\n\t\t// eslint:disable-next-line\n\t\tfor (let i: number = 0; i < this.element[\"selectedOptions\"].length; i++) {\n\t\t\tconst option: HTMLOptionElement = this.element[\"selectedOptions\"][i];\n\t\t\tselected.push(option.value);\n\t\t}\n\n\t\treturn expect(selected);\n\t}\n\n\tpublic trimmedTextContent(): Matchers<any> {\n\t\treturn expect(this.element.textContent.trim());\n\t}\n\n\tpublic textContent(): Matchers<any> {\n\t\treturn expect(this.element.textContent);\n\t}\n\n}\n\nclass OperationsImpl implements Operations {\n\n\tprivate element: HTMLElement;\n\n\tprivate value: string;\n\n\tprivate type: string;\n\n\tconstructor(element: HTMLElement, value: string, type: string) {\n\t\tthis.element = requireNotNull(element, \"element\");\n\t\tthis.value = requireNotNull(value, \"value\");\n\t\tthis.type = requireNotNull(type, \"type\");\n\t}\n\n\tpublic get<E extends HTMLElement>(options?: any): E {\n\t\treturn this.execute(\"get\", options);\n\t}\n\n\tpublic query(options?: any): HTMLElement {\n\t\treturn this.execute(\"query\", options);\n\t}\n\n\tpublic find(options?: any): HTMLElement {\n\t\treturn this.execute(\"find\", options);\n\t}\n\n\tpublic getAll(options?: any): HTMLElement[] {\n\t\treturn this.execute(\"getAll\", options);\n\t}\n\n\tpublic queryAll(options?: any): HTMLElement[] {\n\t\treturn this.execute(\"queryAll\", options);\n\t}\n\n\tpublic findAll(options?: any): HTMLElement[] {\n\t\treturn this.execute(\"findAll\", options);\n\t}\n\n\tpublic expect(options?: any): ExpectionActions {\n\t\tconst element: HTMLElement = this.get(options);\n\n\t\treturn new ExpectionActionsImpl(element);\n\t}\n\n\tpublic appendText(text: string, options?: any): void {\n\t\tconst element: HTMLInputElement = this.get(options) as HTMLInputElement;\n\t\telement.value = element.value + text;\n\t\tfireEvent.input(element);\n\t}\n\n\tpublic replaceText(text: string, options?: any): void {\n\t\tconst element: HTMLInputElement = this.get(options) as HTMLInputElement;\n\t\telement.value = text;\n\t\tfireEvent.input(element);\n\t}\n\n\tpublic selectIndex(index: number, options?: any): void {\n\t\tconst element: HTMLSelectElement = this.get(options) as HTMLSelectElement;\n\t\telement.selectedIndex = index;\n\t\tfireEvent.change(element);\n\t}\n\n\tpublic selectIndexes(indexes: number[], options?: any): void {\n\t\tconst element: HTMLSelectElement = this.get(options) as HTMLSelectElement;\n\n\t\t// eslint:disable-next-line\n\t\tfor (let i: number = 0; i < element.options.length; i++) {\n\t\t\tconst option: HTMLOptionElement = element.options[i];\n\t\t\toption.selected = false;\n\t\t}\n\n\t\t// eslint:disable-next-line\n\t\tfor (let i: number = 0; i < indexes.length; i++) {\n\t\t\tconst index: number = indexes[i];\n\t\t\tconst option: HTMLOptionElement = element.options[index];\n\t\t\toption.selected = true;\n\t\t}\n\n\t\tfireEvent.change(element);\n\t}\n\n\tpublic setCheckedState(value: boolean, options?: any): void {\n\t\tconst element: HTMLInputElement = this.get(options) as HTMLInputElement;\n\t\telement.checked = value;\n\t\tfireEvent.input(element);\n\t}\n\n\tprivate execute<T>(name: string, options: any): T {\n\t\tconst methodName: string = name + \"By\" + this.type;\n\n\t\treturn queries[methodName](this.element, this.value, options) as T;\n\t}\n\n}\n\nclass Harness<C extends Nestable> {\n\n\tprivate document: Document;\n\n\tprivate window: Window;\n\n\tprivate stage: Stage;\n\n\tprivate rootSupplier: () => C;\n\n\tprivate actualProperties: any;\n\n\tprivate initialProperties: any;\n\n\tprivate root: C;\n\n\tconstructor(rootSupplier: () => C = DEFAULT_COMPONENT_SUPPLIER as () => C, properties?: any) {\n\t\tthis.rootSupplier = requireNotNull(rootSupplier, \"rootSupplier\");\n\t\tthis.actualProperties = isDefined(properties) ? properties : {};\n\t\tthis.reset();\n\t}\n\n\tpublic reset(): void {\n\t\tthis.stop();\n\n\t\tthis.window = new JSDOM(HTML).window as unknown as Window;\n\t\tthis.document = this.window.document;\n\n\t\tconst defaultProperties: any = {\n\t\t\t[PropertyKeys.CYDRAN_STARTUP_SYNCHRONOUS]: true,\n\t\t\t[PropertyKeys.CYDRAN_LOG_LEVEL]: \"WARN\",\n\t\t\t[PropertyKeys.CYDRAN_OVERRIDE_WINDOW]: this.window\n\t\t};\n\n\t\tthis.initialProperties = merge([defaultProperties, this.actualProperties]);\n\n\t\tthis.stage = create(\"body\", this.initialProperties);\n\t\tthis.stage.addInitializer({}, (stage: Stage) => {\n\t\t\tthis.root = this.rootSupplier();\n\t\t\tstage.setComponent(this.root);\n\t\t});\n\t}\n\n\tpublic start(): Harness<C> {\n\t\tthis.stage.start();\n\n\t\treturn this;\n\t}\n\n\tpublic stop(): Harness<C> {\n\t\tif (isDefined(this.stage) && this.stage.isStarted()) {\n\t\t\tthis.stage.$release();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tpublic getComponent(): C {\n\t\treturn this.root;\n\t}\n\n\tpublic getWindow(): Window {\n\t\treturn this.window;\n\t}\n\n\tpublic getDocument(): Document {\n\t\treturn this.document;\n\t}\n\n\tpublic getContext(): Context {\n\t\treturn this.stage.getContext();\n\t}\n\n\tpublic getStage(): Stage {\n\t\treturn this.stage;\n\t}\n\n\tpublic registerConstant(id: string, instance: any): void {\n\t\tthis.stage.getContext().registerConstant(id, instance);\n\t}\n\n\tpublic registerPrototype(id: string, classInstance: Type<any>, resolvers?: ArgumentsResolvers): void {\n\t\tthis.stage.getContext().registerPrototype(id, classInstance, resolvers);\n\t}\n\n\tpublic registerSingleton(id: string, classInstance: Type<any>, resolvers?: ArgumentsResolvers): void {\n\t\tthis.stage.getContext().registerSingleton(id, classInstance, resolvers);\n\t}\n\n\tpublic forRole(value: string): Operations {\n\t\treturn new OperationsImpl(this.document.documentElement, value, \"Role\");\n\t}\n\n\tpublic forLabelText(value: string): Operations {\n\t\treturn new OperationsImpl(this.document.documentElement, value, \"LabelText\");\n\t}\n\n\tpublic forPlaceholderText(value: string): Operations {\n\t\treturn new OperationsImpl(this.document.documentElement, value, \"PlaceholderText\");\n\t}\n\n\tpublic forText(value: string): Operations {\n\t\treturn new OperationsImpl(this.document.documentElement, value, \"Text\");\n\t}\n\n\tpublic forDisplayValue(value: string): Operations {\n\t\treturn new OperationsImpl(this.document.documentElement, value, \"DisplayValue\");\n\t}\n\n\tpublic forAltText(value: string): Operations {\n\t\treturn new OperationsImpl(this.document.documentElement, value, \"AltText\");\n\t}\n\n\tpublic forTitle(value: string): Operations {\n\t\treturn new OperationsImpl(this.document.documentElement, value, \"Title\");\n\t}\n\n\tpublic forTestId(value: string): Operations {\n\t\treturn new OperationsImpl(this.document.documentElement, value, \"TestId\");\n\t}\n\n\tpublic expectBody(): Matchers<any> {\n\t\treturn expect(this.document.body.innerHTML);\n\t}\n\n}\n\nexport default Harness;\n", "import Harness from 'harness/Harness';\n\nfunction isDefined(value: any): boolean {\n\treturn value !== null && value !== undefined;\n}\n\nfunction requireNotNull<T>(value: T, name: string): T {\n\tif (value === null || value === undefined) {\n\t\tthrow new Error(`${ name } shall not be null`);\n\t}\n\n\treturn value;\n}\n\nfunction merge<T>(sources: any[]): T {\n\trequireNotNull(sources, \"sources\");\n\n\treturn overlay({} as T, sources);\n}\n\nfunction overlay<T>(destination: T, sources: any[]): T {\n\trequireNotNull(destination, \"destination\");\n\trequireNotNull(sources, \"sources\");\n\n\tfor (const source of sources) {\n\t\tif (!isDefined(source)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (const name in source) {\n\t\t\tif (!source.hasOwnProperty(name)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!isDefined(source[name])) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tdestination[name] = source[name];\n\t\t}\n\t}\n\n\treturn destination;\n}\n\nexport {\n\tHarness, overlay, merge, requireNotNull, isDefined\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,UAAA,UAAA,UAAA,OAAA;AACA,UAAA,WAAA,UAAA,gBAAA;AACA,UAAA,QAAA,UAAA,sBAAA;AACA,UAAA,YAAA,UAAA,eAAA;AAGA,UAAM,gBAAN,cAA4B,SAAA,UAAS;QAEpC,cAAA;AACC,gBAAM,aAAa;QACpB;;AAID,UAAM,
|
|
4
|
+
"sourcesContent": ["import { JSDOM } from 'jsdom';\nimport { Nestable, requireNotNull, isDefined, Stage, Context, Type, merge, ArgumentsResolvers, PropertyKeys, Component, create, SimpleMap } from \"@cydran/cydran\";\nimport { queries, fireEvent } from '@testing-library/dom';\nimport { expect } from '@jest/globals';\nimport { Matchers } from 'expect';\n\nclass TestComponent extends Component {\n\t\n\tconstructor() {\n\t\tsuper(\"<div></div>\");\n\t}\n\n}\n\nconst DEFAULT_COMPONENT_SUPPLIER: () => Nestable = () => new TestComponent();\n\nconst HTML: string = `<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<title>Cydran Test Harness</title>\n\t</head>\n\t<body>\n\t\t<!-- Stage Content -->\n\t</body>\n</html>`;\n\ninterface ExpectionActions {\n\n\tselectedValues(): Matchers<void, string[]>;\n\n\ttrimmedTextContent(): Matchers<void, string>;\n\n\ttextContent(): Matchers<void, string>;\n\n}\n\ninterface Operations {\n\n\tget<E extends HTMLElement>(options?: unknown): E;\n\n\tquery(options?: unknown): HTMLElement;\n\n\tfind(options?: unknown): HTMLElement;\n\n\tgetAll(options?: unknown): HTMLElement[];\n\n\tqueryAll(options?: unknown): HTMLElement[];\n\n\tfindAll(options?: unknown): HTMLElement[];\n\n\texpect(options?: unknown): ExpectionActions;\n\n\tappendText(text: string, options?: unknown): void;\n\n\treplaceText(text: string, options?: unknown): void;\n\n\tselectIndex(index: number, options?: unknown): void;\n\n\tselectIndexes(indexes: number[], options?: unknown): void;\n\n\tsetCheckedState(options?: unknown): void;\n\n}\n\nclass ExpectionActionsImpl implements ExpectionActions {\n\n\tprivate element: HTMLElement;\n\n\tconstructor(element: HTMLElement) {\n\t\tthis.element = requireNotNull(element, \"element\");\n\t}\n\n\tpublic selectedValues(): Matchers<void, string[]> {\n\t\tconst selected: string[] = [];\n\n\t\tfor (let i: number = 0; i < this.element[\"selectedOptions\"].length; i++) {\n\t\t\tconst option: HTMLOptionElement = this.element[\"selectedOptions\"][i];\n\t\t\tselected.push(option.value);\n\t\t}\n\n\t\treturn expect(selected);\n\t}\n\n\tpublic trimmedTextContent(): Matchers<void, string> {\n\t\treturn expect(this.element.textContent.trim());\n\t}\n\n\tpublic textContent(): Matchers<void, string> {\n\t\treturn expect(this.element.textContent);\n\t}\n\n}\n\nclass OperationsImpl implements Operations {\n\n\tprivate element: HTMLElement;\n\n\tprivate value: string;\n\n\tprivate type: string;\n\n\tconstructor(element: HTMLElement, value: string, type: string) {\n\t\tthis.element = requireNotNull(element, \"element\");\n\t\tthis.value = requireNotNull(value, \"value\");\n\t\tthis.type = requireNotNull(type, \"type\");\n\t}\n\n\tpublic get<E extends HTMLElement>(options?: unknown): E {\n\t\treturn this.execute(\"get\", options);\n\t}\n\n\tpublic query(options?: unknown): HTMLElement {\n\t\treturn this.execute(\"query\", options);\n\t}\n\n\tpublic find(options?: unknown): HTMLElement {\n\t\treturn this.execute(\"find\", options);\n\t}\n\n\tpublic getAll(options?: unknown): HTMLElement[] {\n\t\treturn this.execute(\"getAll\", options);\n\t}\n\n\tpublic queryAll(options?: unknown): HTMLElement[] {\n\t\treturn this.execute(\"queryAll\", options);\n\t}\n\n\tpublic findAll(options?: unknown): HTMLElement[] {\n\t\treturn this.execute(\"findAll\", options);\n\t}\n\n\tpublic expect(options?: unknown): ExpectionActions {\n\t\tconst element: HTMLElement = this.get(options);\n\n\t\treturn new ExpectionActionsImpl(element);\n\t}\n\n\tpublic appendText(text: string, options?: unknown): void {\n\t\tconst element: HTMLInputElement = this.get(options) as HTMLInputElement;\n\t\telement.value = element.value + text;\n\t\tfireEvent.input(element);\n\t}\n\n\tpublic replaceText(text: string, options?: unknown): void {\n\t\tconst element: HTMLInputElement = this.get(options) as HTMLInputElement;\n\t\telement.value = text;\n\t\tfireEvent.input(element);\n\t}\n\n\tpublic selectIndex(index: number, options?: unknown): void {\n\t\tconst element: HTMLSelectElement = this.get(options) as HTMLSelectElement;\n\t\telement.selectedIndex = index;\n\t\tfireEvent.change(element);\n\t}\n\n\tpublic selectIndexes(indexes: number[], options?: unknown): void {\n\t\tconst element: HTMLSelectElement = this.get(options) as HTMLSelectElement;\n\n\t\tfor (let i: number = 0; i < element.options.length; i++) {\n\t\t\tconst option: HTMLOptionElement = element.options[i];\n\t\t\toption.selected = false;\n\t\t}\n\n\t\tfor (let i: number = 0; i < indexes.length; i++) {\n\t\t\tconst index: number = indexes[i];\n\t\t\tconst option: HTMLOptionElement = element.options[index];\n\t\t\toption.selected = true;\n\t\t}\n\n\t\tfireEvent.change(element);\n\t}\n\n\tpublic setCheckedState(value: boolean, options?: unknown): void {\n\t\tconst element: HTMLInputElement = this.get(options) as HTMLInputElement;\n\t\telement.checked = value;\n\t\tfireEvent.input(element);\n\t}\n\n\tprivate execute<T>(name: string, options: unknown): T {\n\t\tconst methodName: string = name + \"By\" + this.type;\n\n\t\treturn queries[methodName](this.element, this.value, options) as T;\n\t}\n\n}\n\nclass Harness<C extends Nestable> {\n\n\tprivate document: Document;\n\n\tprivate window: Window;\n\n\tprivate stage: Stage;\n\n\tprivate rootSupplier: () => C;\n\n\tprivate actualProperties: SimpleMap<unknown>;\n\n\tprivate initialProperties: SimpleMap<unknown>;\n\n\tprivate root: C;\n\n\tconstructor(rootSupplier: () => C = DEFAULT_COMPONENT_SUPPLIER as () => C, properties?: SimpleMap<unknown>) {\n\t\tthis.rootSupplier = requireNotNull(rootSupplier, \"rootSupplier\");\n\t\tthis.actualProperties = isDefined(properties) ? properties : {} as SimpleMap<unknown>;\n\t\tthis.reset();\n\t}\n\n\tpublic reset(): void {\n\t\tthis.stop();\n\n\t\tthis.window = new JSDOM(HTML).window as unknown as Window;\n\t\tthis.document = this.window.document;\n\n\t\tconst defaultProperties: object = {\n\t\t\t[PropertyKeys.CYDRAN_STARTUP_SYNCHRONOUS]: true,\n\t\t\t[PropertyKeys.CYDRAN_LOG_LEVEL]: \"WARN\",\n\t\t\t[PropertyKeys.CYDRAN_OVERRIDE_WINDOW]: this.window\n\t\t};\n\n\t\tthis.initialProperties = merge([defaultProperties, this.actualProperties]);\n\n\t\tthis.stage = create(\"body\", this.initialProperties);\n\t\tthis.stage.addInitializer({}, (stage: Stage) => {\n\t\t\tthis.root = this.rootSupplier();\n\t\t\tstage.setComponent(this.root);\n\t\t});\n\t}\n\n\tpublic start(): Harness<C> {\n\t\tthis.stage.start();\n\n\t\treturn this;\n\t}\n\n\tpublic stop(): Harness<C> {\n\t\tif (isDefined(this.stage) && this.stage.isStarted()) {\n\t\t\tthis.stage.$release();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tpublic getComponent(): C {\n\t\treturn this.root;\n\t}\n\n\tpublic getWindow(): Window {\n\t\treturn this.window;\n\t}\n\n\tpublic getDocument(): Document {\n\t\treturn this.document;\n\t}\n\n\tpublic getContext(): Context {\n\t\treturn this.stage.getContext();\n\t}\n\n\tpublic getStage(): Stage {\n\t\treturn this.stage;\n\t}\n\n\tpublic registerConstant<T>(id: string, instance: T): void {\n\t\tthis.stage.getContext().registerConstant(id, instance);\n\t}\n\n\tpublic registerPrototype<T>(id: string, classInstance: Type<T>, resolvers?: ArgumentsResolvers): void {\n\t\tthis.stage.getContext().registerPrototype(id, classInstance, resolvers);\n\t}\n\n\tpublic registerSingleton<T>(id: string, classInstance: Type<T>, resolvers?: ArgumentsResolvers): void {\n\t\tthis.stage.getContext().registerSingleton(id, classInstance, resolvers);\n\t}\n\n\n\tpublic registerConstantGlobally<T>(id: string, instance: T): void {\n\t\tthis.stage.getContext()[\"obscuredParent\"].registerConstant(id, instance);\n\t}\n\n\tpublic registerPrototypeGlobally<T>(id: string, classInstance: Type<T>, resolvers?: ArgumentsResolvers): void {\n\t\tthis.stage.getContext()[\"obscuredParent\"].registerPrototype(id, classInstance, resolvers);\n\t}\n\n\tpublic registerSingletonGlobally<T>(id: string, classInstance: Type<T>, resolvers?: ArgumentsResolvers): void {\n\t\tthis.stage.getContext()[\"obscuredParent\"].registerSingleton(id, classInstance, resolvers);\n\t}\n\n\n\tpublic forRole(value: string): Operations {\n\t\treturn new OperationsImpl(this.document.documentElement, value, \"Role\");\n\t}\n\n\tpublic forLabelText(value: string): Operations {\n\t\treturn new OperationsImpl(this.document.documentElement, value, \"LabelText\");\n\t}\n\n\tpublic forPlaceholderText(value: string): Operations {\n\t\treturn new OperationsImpl(this.document.documentElement, value, \"PlaceholderText\");\n\t}\n\n\tpublic forText(value: string): Operations {\n\t\treturn new OperationsImpl(this.document.documentElement, value, \"Text\");\n\t}\n\n\tpublic forDisplayValue(value: string): Operations {\n\t\treturn new OperationsImpl(this.document.documentElement, value, \"DisplayValue\");\n\t}\n\n\tpublic forAltText(value: string): Operations {\n\t\treturn new OperationsImpl(this.document.documentElement, value, \"AltText\");\n\t}\n\n\tpublic forTitle(value: string): Operations {\n\t\treturn new OperationsImpl(this.document.documentElement, value, \"Title\");\n\t}\n\n\tpublic forTestId(value: string): Operations {\n\t\treturn new OperationsImpl(this.document.documentElement, value, \"TestId\");\n\t}\n\n\tpublic expectBody(): Matchers<void, string> {\n\t\treturn expect(this.document.body.innerHTML) as Matchers<void, string>;\n\t}\n\n}\n\nexport default Harness;\n", "import Harness from 'harness/Harness';\n\nfunction isDefined<T>(value: T): boolean {\n\treturn value !== null && value !== undefined;\n}\n\nfunction requireNotNull<T>(value: T, name: string): T {\n\tif (value === null || value === undefined) {\n\t\tthrow new Error(`${ name } shall not be null`);\n\t}\n\n\treturn value;\n}\n\nfunction merge<T>(sources: unknown[]): T {\n\trequireNotNull(sources, \"sources\");\n\n\treturn overlay({} as T, sources);\n}\n\nfunction overlay<T>(destination: T, sources: unknown[]): T {\n\trequireNotNull(destination, \"destination\");\n\trequireNotNull(sources, \"sources\");\n\n\tfor (const source of sources) {\n\t\tif (!isDefined(source)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (const name of Object.keys(source)) {\n\t\t\tif (!isDefined(source[name])) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tdestination[name] = source[name];\n\t\t}\n\t}\n\n\treturn destination;\n}\n\nexport {\n\tHarness, overlay, merge, requireNotNull, isDefined\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,UAAA,UAAA,UAAA,OAAA;AACA,UAAA,WAAA,UAAA,gBAAA;AACA,UAAA,QAAA,UAAA,sBAAA;AACA,UAAA,YAAA,UAAA,eAAA;AAGA,UAAM,gBAAN,cAA4B,SAAA,UAAS;QAEpC,cAAA;AACC,gBAA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AA0CC,cAAA,UA1CM,UAAA;AAEP,eAAS,UAAa,OAAQ;AAC7B,eAAO,UAAU,QAAQ,UAAU;MACpC;AAEA,eAAS,eAAkB,OAAU,MAAY;AAChD,YAAI,UAAU,QAAQ,UAAU,QAAW;AAC1C,gBAAM,IAAI,MAAM,GAAI,IAAK,oBAAoB;QAC9C;AAEA,eAAO;MACR;AAEA,eAAS,MAAS,SAAkB;AACnC,uBAAe,SAAS,SAAS;AAEjC,eAAO,QAAQ,CAAA,GAAS,OAAO;MAChC;AAEA,eAAS,QAAW,aAAgB,SAAkB;AACrD,uBAAe,aAAa,aAAa;AACzC,uBAAe,SAAS,SAAS;AAEjC,mBAAW,UAAU,SAAS;AAC7B,cAAI,CAAC,UAAU,MAAM,GAAG;AACvB;UACD;AAEA,qBAAW,QAAQ,OAAO,KAAK,MAAM,GAAG;AACvC,gBAAI,CAAC,UAAU,OAAO,IAAI,CAAC,GAAG;AAC7B;YACD;AAEA,wBAAY,IAAI,IAAI,OAAO,IAAI;UAChC;QACD;AAEA,eAAO;MACR;;;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cydran/testsupport",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Testing support for Cydran",
|
|
5
5
|
"module": "dist/testsupport.js",
|
|
6
6
|
"main": "dist/testsupport.js",
|
|
@@ -12,12 +12,7 @@
|
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
|
-
"
|
|
16
|
-
"lint.src": "npx eslint -c ./conf/.eslintrc.js --ext .ts src",
|
|
17
|
-
"lint.packageJson": "npx npm-package-json-lint .",
|
|
18
|
-
"validate": "npm run dependency-validate && npm run tests-validate",
|
|
19
|
-
"dependency-validate": "npx depcruise --validate --config ./conf/.dependency-cruiser.js src",
|
|
20
|
-
"tests-validate": "node tools/check-unit-tests.js",
|
|
15
|
+
"validate": "npx @cydran/build validate",
|
|
21
16
|
"build": "npm run clean && npm run transpile && npm run aggregate",
|
|
22
17
|
"build.all": "npm run build.release && npm run docs",
|
|
23
18
|
"clean": "npm run clean.dist && npm run clean.coverage && npm run clean.tarball",
|
|
@@ -30,12 +25,6 @@
|
|
|
30
25
|
"aggregate.js": "node esbuild.js",
|
|
31
26
|
"aggregate.clean": "npx rimraf --glob dist/src",
|
|
32
27
|
"test": "npx @cydran/build test",
|
|
33
|
-
"release.patch": "npm version patch && npm run orchestrate.release",
|
|
34
|
-
"release.minor": "npm version minor && npm run orchestrate.release",
|
|
35
|
-
"release.major": "npm version major && npm run orchestrate.release",
|
|
36
|
-
"orchestrate.release": "npm run build.release && npm pack && npm run publish.release",
|
|
37
|
-
"publish.release": "git push --follow-tags origin master && npm publish",
|
|
38
|
-
"pkg.check": "npm --dry-run pack",
|
|
39
28
|
"docs": "npx rimraf --glob docs && npx typedoc --options ./typedoc.json --tsconfig ./tsconfig.json ./src",
|
|
40
29
|
"docsification": "docsify --help"
|
|
41
30
|
},
|
|
@@ -71,21 +60,16 @@
|
|
|
71
60
|
"@babel/plugin-transform-modules-umd": "7.24.7",
|
|
72
61
|
"@babel/preset-env": "7.25.4",
|
|
73
62
|
"@babel/preset-typescript": "7.24.7",
|
|
74
|
-
"@cydran/build": "^0.
|
|
63
|
+
"@cydran/build": "^0.5.0",
|
|
75
64
|
"@types/lodash": "4.17.7",
|
|
76
65
|
"@types/node": "22.5.4",
|
|
77
|
-
"@typescript-eslint/eslint-plugin": "8.5.0",
|
|
78
|
-
"@typescript-eslint/parser": "8.5.0",
|
|
79
66
|
"babel-preset-es2015": "6.24.1",
|
|
80
67
|
"cross-env": "7.0.3",
|
|
81
|
-
"dependency-cruiser": "16.4.1",
|
|
82
68
|
"docpress": "0.8.2",
|
|
83
69
|
"dts-bundle-generator": "9.5.1",
|
|
84
70
|
"esbuild": "0.23.1",
|
|
85
|
-
"eslint": "8.57.0",
|
|
86
71
|
"expose-gc": "1.0.0",
|
|
87
72
|
"fs-extra": "11.2.0",
|
|
88
|
-
"npm-package-json-lint": "8.0.0",
|
|
89
73
|
"requirejs": "2.3.7",
|
|
90
74
|
"rimraf": "6.0.1",
|
|
91
75
|
"source-map-support": "0.5.21",
|
|
@@ -95,7 +79,7 @@
|
|
|
95
79
|
"typescript": "5.6.2"
|
|
96
80
|
},
|
|
97
81
|
"dependencies": {
|
|
98
|
-
"@cydran/cydran": "^0.
|
|
82
|
+
"@cydran/cydran": "^0.5.0",
|
|
99
83
|
"@jest/globals": "29.7.0",
|
|
100
84
|
"@testing-library/dom": "10.4.0",
|
|
101
85
|
"@testing-library/jest-dom": "6.5.0",
|
|
@@ -110,5 +94,5 @@
|
|
|
110
94
|
"docpress": {
|
|
111
95
|
"dist": "dist/docs"
|
|
112
96
|
},
|
|
113
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "95ff4d00cde7d665a28a0003f574668902ba14ec"
|
|
114
98
|
}
|