@cydran/testsupport 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/testsupport.d.ts +107 -101
- package/dist/testsupport.js +11 -5
- package/dist/testsupport.js.map +2 -2
- package/package.json +6 -22
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,22 @@ 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
|
-
export interface ActionContinuation extends Tellable, Messagable
|
|
76
|
+
export interface ActionContinuation extends Tellable, Messagable {
|
|
77
|
+
onExpressionValueChange(expression: string): WatchContinuation;
|
|
78
|
+
/**
|
|
79
|
+
* Evaluates an expression.
|
|
80
|
+
* @param expression Expression to evaluate.
|
|
81
|
+
*/
|
|
82
|
+
evaluate<T>(expression: string): T;
|
|
70
83
|
getParent(): Nestable;
|
|
71
84
|
getEl(): HTMLElement;
|
|
72
|
-
getObject<T>(id: string, ...instanceArguments:
|
|
85
|
+
getObject<T>(id: string, ...instanceArguments: unknown[]): T;
|
|
73
86
|
getLogger(): Logger;
|
|
74
87
|
properties(): Properties;
|
|
75
88
|
getId(): string;
|
|
@@ -79,8 +92,8 @@ export interface ActionContinuation extends Tellable, Messagable, Watchable {
|
|
|
79
92
|
getValue<T>(): T;
|
|
80
93
|
isMounted(): boolean;
|
|
81
94
|
isConnected(): boolean;
|
|
82
|
-
send(messageName: string, payload?:
|
|
83
|
-
onInterval(millis?:
|
|
95
|
+
send(messageName: string, payload?: unknown): SendContinuation;
|
|
96
|
+
onInterval(millis?: number): IntervalContinuation;
|
|
84
97
|
onMessage(messageName: string): OnContinuation;
|
|
85
98
|
/**
|
|
86
99
|
* Get a {@linkcode FilterBuilder} object back to create a {@linkcode Filter} of lists in the model
|
|
@@ -89,7 +102,7 @@ export interface ActionContinuation extends Tellable, Messagable, Watchable {
|
|
|
89
102
|
*/
|
|
90
103
|
createFilter(expression: string): FilterBuilder;
|
|
91
104
|
regions(): RegionContinuation;
|
|
92
|
-
tell(name: string, payload?:
|
|
105
|
+
tell(name: string, payload?: unknown): void;
|
|
93
106
|
forElement<E extends HTMLElement>(name: string): ElementOperations<E>;
|
|
94
107
|
forSeries(name: string): SeriesOperations;
|
|
95
108
|
forForm(name: string): FormOperations;
|
|
@@ -107,20 +120,21 @@ export interface Actionable<T> {
|
|
|
107
120
|
$c(): T;
|
|
108
121
|
}
|
|
109
122
|
export interface ArgumentsResolvers {
|
|
110
|
-
resolve(context:
|
|
111
|
-
postProcess(context:
|
|
123
|
+
resolve(context: unknown, instanceArguments: unknown[]): unknown[];
|
|
124
|
+
postProcess(context: unknown, targetObject: unknown, params: unknown[]): void;
|
|
112
125
|
}
|
|
113
126
|
export interface ComponentOptions {
|
|
114
|
-
metadata?: SimpleMap<
|
|
127
|
+
metadata?: SimpleMap<unknown>;
|
|
115
128
|
prefix?: string;
|
|
116
129
|
styles?: string;
|
|
130
|
+
name?: string;
|
|
117
131
|
}
|
|
118
132
|
export interface Context extends Sendable, Register<Context>, Tellable, Receivable {
|
|
119
133
|
getChild(name: string): Context;
|
|
120
134
|
hasChild(name: string): boolean;
|
|
121
135
|
addChild(name: string, initializer?: (context: Context) => void): Context;
|
|
122
136
|
removeChild(name: string): Context;
|
|
123
|
-
getObject<T>(id: string, ...instanceArguments:
|
|
137
|
+
getObject<T>(id: string, ...instanceArguments: unknown[]): T;
|
|
124
138
|
getProperties(): MutableProperties;
|
|
125
139
|
getScope(): Scope;
|
|
126
140
|
getRoot(): Context;
|
|
@@ -129,12 +143,12 @@ export interface Context extends Sendable, Register<Context>, Tellable, Receivab
|
|
|
129
143
|
registerImplicit(id: string, template: string, options?: ComponentOptions): Context;
|
|
130
144
|
getName(): string;
|
|
131
145
|
getFullName(): string;
|
|
132
|
-
addPreInitializer(thisObject:
|
|
133
|
-
addInitializer(thisObject:
|
|
134
|
-
addDisposer(thisObject:
|
|
135
|
-
configure(callback: (context: Context) => void, thisObject?:
|
|
136
|
-
addListener(thisObject:
|
|
137
|
-
removeListener(thisObject:
|
|
146
|
+
addPreInitializer(thisObject: CallBackThisObject, callback: (context?: Context) => void): void;
|
|
147
|
+
addInitializer(thisObject: CallBackThisObject, callback: (context?: Context) => void): void;
|
|
148
|
+
addDisposer(thisObject: CallBackThisObject, callback: (context?: Context) => void): void;
|
|
149
|
+
configure(callback: (context: Context) => void, thisObject?: CallBackThisObject): Context;
|
|
150
|
+
addListener(thisObject: CallBackThisObject, callback: MessageCallback): void;
|
|
151
|
+
removeListener(thisObject: CallBackThisObject, callback: MessageCallback): void;
|
|
138
152
|
}
|
|
139
153
|
export interface DestinationContinuation {
|
|
140
154
|
withPropagation(propagation: To): void;
|
|
@@ -146,16 +160,16 @@ export interface ElementOperations<E extends HTMLElement> {
|
|
|
146
160
|
blur(): void;
|
|
147
161
|
}
|
|
148
162
|
export interface ExpectionActions {
|
|
149
|
-
selectedValues(): Matchers<
|
|
150
|
-
trimmedTextContent(): Matchers<
|
|
151
|
-
textContent(): Matchers<
|
|
163
|
+
selectedValues(): Matchers<void, string[]>;
|
|
164
|
+
trimmedTextContent(): Matchers<void, string>;
|
|
165
|
+
textContent(): Matchers<void, string>;
|
|
152
166
|
}
|
|
153
167
|
export interface Filter {
|
|
154
168
|
/**
|
|
155
169
|
* Get the resulting array of items after the filter has been applied
|
|
156
170
|
* @returns array of filtered objects
|
|
157
171
|
*/
|
|
158
|
-
items():
|
|
172
|
+
items(): unknown[];
|
|
159
173
|
/**
|
|
160
174
|
* Extend a {Filter filter} instance
|
|
161
175
|
* @returns a {FilterBuilder} object
|
|
@@ -164,8 +178,8 @@ export interface Filter {
|
|
|
164
178
|
}
|
|
165
179
|
export interface FilterBuilder {
|
|
166
180
|
withPredicate(expression: string, ...parameterExpressions: string[]): FilterBuilder;
|
|
167
|
-
withPhase(fn: (input:
|
|
168
|
-
withSimplePredicate(predicate: (index: number, value:
|
|
181
|
+
withPhase(fn: (input: unknown[]) => unknown[]): FilterBuilder;
|
|
182
|
+
withSimplePredicate(predicate: (index: number, value: unknown) => boolean): FilterBuilder;
|
|
169
183
|
withSort(expression: string, ...parameterExpressions: string[]): FilterBuilder;
|
|
170
184
|
withLimit(limit: number): FilterBuilder;
|
|
171
185
|
with(fn: (builder: FilterBuilder) => void): FilterBuilder;
|
|
@@ -174,7 +188,7 @@ export interface FilterBuilder {
|
|
|
174
188
|
limited(): LimitOffsetFilter;
|
|
175
189
|
}
|
|
176
190
|
export interface ForChannelContinuation {
|
|
177
|
-
invoke(
|
|
191
|
+
invoke(name: string, before?: () => void, after?: () => void): void;
|
|
178
192
|
}
|
|
179
193
|
export interface FormOperations {
|
|
180
194
|
submit(): void;
|
|
@@ -182,7 +196,7 @@ export interface FormOperations {
|
|
|
182
196
|
reset(): void;
|
|
183
197
|
}
|
|
184
198
|
export interface IntervalContinuation {
|
|
185
|
-
invoke(
|
|
199
|
+
invoke(name: string): void;
|
|
186
200
|
}
|
|
187
201
|
export interface IsLevelType {
|
|
188
202
|
/**
|
|
@@ -239,80 +253,80 @@ export interface Logger extends IsLevelType {
|
|
|
239
253
|
* @param primaryMsg to be written out
|
|
240
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
|
|
241
255
|
*/
|
|
242
|
-
trace(primaryMsg: string, ...moreArgs:
|
|
256
|
+
trace(primaryMsg: string, ...moreArgs: unknown[]): void;
|
|
243
257
|
/**
|
|
244
258
|
* Log payload at a "debug" level
|
|
245
259
|
* @param primaryMsg to be written out
|
|
246
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
|
|
247
261
|
*/
|
|
248
|
-
debug(primaryMsg: string, ...moreArgs:
|
|
262
|
+
debug(primaryMsg: string, ...moreArgs: unknown[]): void;
|
|
249
263
|
/**
|
|
250
264
|
* Log payload at a "info" level
|
|
251
265
|
* @param primaryMsg to be written out
|
|
252
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
|
|
253
267
|
*/
|
|
254
|
-
info(primaryMsg: string, ...moreArgs:
|
|
268
|
+
info(primaryMsg: string, ...moreArgs: unknown[]): void;
|
|
255
269
|
/**
|
|
256
270
|
* Log payload at a "warn" level
|
|
257
271
|
* @param primaryMsg to be written out
|
|
258
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
|
|
259
273
|
*/
|
|
260
|
-
warn(primaryMsg: string, ...moreArgs:
|
|
274
|
+
warn(primaryMsg: string, ...moreArgs: unknown[]): void;
|
|
261
275
|
/**
|
|
262
276
|
* Log payload at a "error" level
|
|
263
277
|
* @param primaryMsg to be written out
|
|
264
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
|
|
265
279
|
*/
|
|
266
|
-
error(primaryMsg: string, ...moreArgs:
|
|
280
|
+
error(primaryMsg: string, ...moreArgs: unknown[]): void;
|
|
267
281
|
/**
|
|
268
282
|
* Log payload at a "fatal" level
|
|
269
283
|
* @param primaryMsg to be written out
|
|
270
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
|
|
271
285
|
*/
|
|
272
|
-
fatal(primaryMsg: string, ...moreArgs:
|
|
286
|
+
fatal(primaryMsg: string, ...moreArgs: unknown[]): void;
|
|
273
287
|
/**
|
|
274
288
|
* Only if log at a "trace" level execute fn() to derive payload to log
|
|
275
289
|
* @param primaryMsgFn result of to be written out
|
|
276
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
|
|
277
291
|
*/
|
|
278
|
-
ifTrace(primaryMsgFn: () =>
|
|
292
|
+
ifTrace(primaryMsgFn: () => unknown, ...moreArgs: unknown[]): void;
|
|
279
293
|
/**
|
|
280
294
|
* Only if log at a "debug" level execute fn() to derive payload to log
|
|
281
295
|
* @param primaryMsgFn result of to be written out
|
|
282
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
|
|
283
297
|
*/
|
|
284
|
-
ifDebug(primaryMsgFn: () =>
|
|
298
|
+
ifDebug(primaryMsgFn: () => unknown, ...moreArgs: unknown[]): void;
|
|
285
299
|
/**
|
|
286
300
|
* Only if log at a "info" level execute fn() to derive payload to log
|
|
287
301
|
* @param primaryMsgFn result of to be written out
|
|
288
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
|
|
289
303
|
*/
|
|
290
|
-
ifInfo(primaryMsgFn: () =>
|
|
304
|
+
ifInfo(primaryMsgFn: () => unknown, ...moreArgs: unknown[]): void;
|
|
291
305
|
/**
|
|
292
306
|
* Only if log at a "warn" level execute fn() to derive payload to log
|
|
293
307
|
* @param primaryMsgFn result of to be written out
|
|
294
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
|
|
295
309
|
*/
|
|
296
|
-
ifWarn(primaryMsgFn: () =>
|
|
310
|
+
ifWarn(primaryMsgFn: () => unknown, ...moreArgs: unknown[]): void;
|
|
297
311
|
/**
|
|
298
312
|
* Only if log at a "error" level execute fn() to derive payload to log
|
|
299
313
|
* @param primaryMsgFn result of to be written out
|
|
300
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
|
|
301
315
|
*/
|
|
302
|
-
ifError(primaryMsgFn: () =>
|
|
316
|
+
ifError(primaryMsgFn: () => unknown, ...moreArgs: unknown[]): void;
|
|
303
317
|
/**
|
|
304
318
|
* Only if log at a "fatal" level execute fn() to derive payload to log
|
|
305
319
|
* @param primaryMsgFn result of to be written out
|
|
306
320
|
* @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
321
|
*/
|
|
308
|
-
ifFatal(primaryMsgFn: () =>
|
|
322
|
+
ifFatal(primaryMsgFn: () => unknown, ...moreArgs: unknown[]): void;
|
|
309
323
|
}
|
|
310
324
|
export interface Messagable {
|
|
311
|
-
send(messageName: string, payload?:
|
|
325
|
+
send(messageName: string, payload?: unknown): SendContinuation;
|
|
312
326
|
}
|
|
313
327
|
export interface MetadataContinuation {
|
|
314
328
|
has: (name: string) => boolean;
|
|
315
|
-
get: (name: string) =>
|
|
329
|
+
get: <T>(name: string) => T;
|
|
316
330
|
}
|
|
317
331
|
export interface MutableProperties extends Properties {
|
|
318
332
|
/**
|
|
@@ -321,13 +335,13 @@ export interface MutableProperties extends Properties {
|
|
|
321
335
|
* @param value - any type of object
|
|
322
336
|
* @returns
|
|
323
337
|
*/
|
|
324
|
-
set(key: string, value:
|
|
338
|
+
set(key: string, value: unknown): MutableProperties;
|
|
325
339
|
/**
|
|
326
340
|
* Load additional properties in
|
|
327
341
|
* @param values - any type of object
|
|
328
342
|
* @returns
|
|
329
343
|
*/
|
|
330
|
-
load(values:
|
|
344
|
+
load(values: SimpleMap<unknown>): MutableProperties;
|
|
331
345
|
/**
|
|
332
346
|
* Remove a specific property by key
|
|
333
347
|
* @param key - string value
|
|
@@ -373,22 +387,22 @@ export interface Nestable extends Actionable<ActionContinuation> {
|
|
|
373
387
|
onRemount(): void;
|
|
374
388
|
}
|
|
375
389
|
export interface OnContinuation {
|
|
376
|
-
invoke(
|
|
390
|
+
invoke(name: string, before?: () => void, after?: () => void): void;
|
|
377
391
|
forChannel(channelName: string): ForChannelContinuation;
|
|
378
392
|
}
|
|
379
393
|
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?:
|
|
394
|
+
get<E extends HTMLElement>(options?: unknown): E;
|
|
395
|
+
query(options?: unknown): HTMLElement;
|
|
396
|
+
find(options?: unknown): HTMLElement;
|
|
397
|
+
getAll(options?: unknown): HTMLElement[];
|
|
398
|
+
queryAll(options?: unknown): HTMLElement[];
|
|
399
|
+
findAll(options?: unknown): HTMLElement[];
|
|
400
|
+
expect(options?: unknown): ExpectionActions;
|
|
401
|
+
appendText(text: string, options?: unknown): void;
|
|
402
|
+
replaceText(text: string, options?: unknown): void;
|
|
403
|
+
selectIndex(index: number, options?: unknown): void;
|
|
404
|
+
selectIndexes(indexes: number[], options?: unknown): void;
|
|
405
|
+
setCheckedState(options?: unknown): void;
|
|
392
406
|
}
|
|
393
407
|
export interface PagedFilter extends Filter {
|
|
394
408
|
getPageSize(): number;
|
|
@@ -408,16 +422,16 @@ export interface PagedFilter extends Filter {
|
|
|
408
422
|
export interface Properties {
|
|
409
423
|
/**
|
|
410
424
|
* Add an observer for all property changes.
|
|
411
|
-
* @param thisObject Object used as this when calling the
|
|
412
|
-
* @param
|
|
425
|
+
* @param thisObject Object that owns and is used as this when calling the named method
|
|
426
|
+
* @param name - name of the method (on thisObject) to be called when any property is changed
|
|
413
427
|
*/
|
|
414
|
-
addObserver(thisObject:
|
|
428
|
+
addObserver(thisObject: CallBackThisObject, name: string): void;
|
|
415
429
|
/**
|
|
416
430
|
* Remove an observer that listened for all property changes.
|
|
417
|
-
* @param thisObject Object
|
|
418
|
-
* @param
|
|
431
|
+
* @param thisObject Object that owns the named method
|
|
432
|
+
* @param name name of the previously-registered method to be removed
|
|
419
433
|
*/
|
|
420
|
-
removeObserver(thisObject:
|
|
434
|
+
removeObserver(thisObject: CallBackThisObject, name: string): void;
|
|
421
435
|
/**
|
|
422
436
|
* Add an observer for a specific property changes, or changes of more general property when the preferred is unavailable.
|
|
423
437
|
* @param thisObject Object used as this when calling the callback
|
|
@@ -425,27 +439,27 @@ export interface Properties {
|
|
|
425
439
|
* @param preferredKey Preferred property key to observe
|
|
426
440
|
* @param prefix Property key prefix for keys which should be included for consideration
|
|
427
441
|
*/
|
|
428
|
-
addFallbackObserver(thisObject:
|
|
442
|
+
addFallbackObserver(thisObject: CallBackThisObject, name: string, preferredKey: string, prefix?: string): void;
|
|
429
443
|
/**
|
|
430
444
|
* Remove an observer for a specific property changes, or changes of more general property when the preferred is unavailable.
|
|
431
|
-
* @param thisObject Object
|
|
432
|
-
* @param
|
|
445
|
+
* @param thisObject Object that owns the named method
|
|
446
|
+
* @param name name of the previously-registered method to be removed
|
|
433
447
|
*/
|
|
434
|
-
removeFallbackObserver(thisObject:
|
|
448
|
+
removeFallbackObserver(thisObject: CallBackThisObject, name: string): void;
|
|
435
449
|
/**
|
|
436
450
|
* Add an observer for specific property.
|
|
437
451
|
* @param key Specific property key
|
|
438
|
-
* @param thisObject Object used as this when calling the
|
|
439
|
-
* @param
|
|
452
|
+
* @param thisObject Object that owns and is used as this when calling the named method
|
|
453
|
+
* @param name name of the method (on thisObject) to be called when the specific property is changed
|
|
440
454
|
*/
|
|
441
|
-
addPropertyObserver(key: string, thisObject:
|
|
455
|
+
addPropertyObserver(key: string, thisObject: CallBackThisObject, name: string): void;
|
|
442
456
|
/**
|
|
443
457
|
* Remove an observer for specific property.
|
|
444
458
|
* @param key Specific property key
|
|
445
|
-
* @param thisObject Object
|
|
446
|
-
* @param
|
|
459
|
+
* @param thisObject Object that owns the named method
|
|
460
|
+
* @param name name of the previously-registered method to remove
|
|
447
461
|
*/
|
|
448
|
-
removePropertyObserver(key: string, thisObject:
|
|
462
|
+
removePropertyObserver(key: string, thisObject: CallBackThisObject, name: string): void;
|
|
449
463
|
snapshot(): MutableProperties;
|
|
450
464
|
/**
|
|
451
465
|
* Get all the keys present in the properties object
|
|
@@ -517,7 +531,7 @@ export interface Receivable {
|
|
|
517
531
|
* @param messageName The name of the message to send.
|
|
518
532
|
* @param payload The optional payload to include with the message.
|
|
519
533
|
*/
|
|
520
|
-
message(channelName: string, messageName: string, payload?:
|
|
534
|
+
message(channelName: string, messageName: string, payload?: unknown): void;
|
|
521
535
|
}
|
|
522
536
|
export interface RegionContinuation {
|
|
523
537
|
/**
|
|
@@ -540,11 +554,11 @@ export interface RegionContinuation {
|
|
|
540
554
|
setByObjectId(name: string, componentName: string, defaultComponentName?: string): void;
|
|
541
555
|
}
|
|
542
556
|
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: () =>
|
|
557
|
+
registerConstant<T>(id: string, instance: T): R;
|
|
558
|
+
registerPrototype<T>(id: string, classInstance: Type<T>, resolvers?: ArgumentsResolvers, localResolution?: boolean): R;
|
|
559
|
+
registerPrototypeWithFactory<T>(id: string, factoryFn: () => T, resolvers?: ArgumentsResolvers, localResolution?: boolean): R;
|
|
560
|
+
registerSingleton<T>(id: string, classInstance: Type<T>, resolvers?: ArgumentsResolvers, localResolution?: boolean): R;
|
|
561
|
+
registerSingletonWithFactory<T>(id: string, factoryFn: () => T, resolvers?: ArgumentsResolvers, localResolution?: boolean): R;
|
|
548
562
|
hasRegistration(id: string): boolean;
|
|
549
563
|
expose(id: string): R;
|
|
550
564
|
}
|
|
@@ -552,7 +566,7 @@ export interface Releasable {
|
|
|
552
566
|
$release(): void;
|
|
553
567
|
}
|
|
554
568
|
export interface Scope {
|
|
555
|
-
add(name: string, item:
|
|
569
|
+
add(name: string, item: unknown): Scope;
|
|
556
570
|
remove(name: string): Scope;
|
|
557
571
|
extend(): Scope;
|
|
558
572
|
}
|
|
@@ -571,7 +585,7 @@ export interface Sendable {
|
|
|
571
585
|
* @param payload The optional payload to include with the message
|
|
572
586
|
* @param startFrom The optional path to the context start the traversal from
|
|
573
587
|
*/
|
|
574
|
-
send(propagation: To, channelName: string, messageName: string, payload?:
|
|
588
|
+
send(propagation: To, channelName: string, messageName: string, payload?: unknown, startFrom?: string): void;
|
|
575
589
|
}
|
|
576
590
|
export interface SeriesOperations {
|
|
577
591
|
getAt<N extends Nestable>(index: number): N;
|
|
@@ -588,9 +602,6 @@ export interface SeriesOperations {
|
|
|
588
602
|
isEmpty(): boolean;
|
|
589
603
|
clear(): void;
|
|
590
604
|
}
|
|
591
|
-
export interface SimpleMap<T> {
|
|
592
|
-
[key: string]: T;
|
|
593
|
-
}
|
|
594
605
|
export interface Stage extends Releasable {
|
|
595
606
|
getContext(): Context;
|
|
596
607
|
before(): SeriesOperations;
|
|
@@ -599,24 +610,19 @@ export interface Stage extends Releasable {
|
|
|
599
610
|
setComponent(component: Nestable): Stage;
|
|
600
611
|
setComponentByObjectId(componentName: string, defaultComponentName?: string): Stage;
|
|
601
612
|
isStarted(): boolean;
|
|
602
|
-
addInitializer(thisObject:
|
|
613
|
+
addInitializer(thisObject: CallBackThisObject, callback: (stage: Stage) => void): Stage;
|
|
603
614
|
}
|
|
604
615
|
export interface Tellable {
|
|
605
|
-
tell(name: string, payload?:
|
|
606
|
-
}
|
|
607
|
-
export interface Type<T> extends Function {
|
|
608
|
-
new (...args: any[]): T;
|
|
616
|
+
tell(name: string, payload?: unknown): void;
|
|
609
617
|
}
|
|
610
|
-
export interface
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
* Evaluates an expression.
|
|
614
|
-
* @param expression Expression to evaluate.
|
|
615
|
-
*/
|
|
616
|
-
evaluate<T>(expression: string): T;
|
|
617
|
-
getWatchScope(): any;
|
|
618
|
+
export interface WatchContinuation {
|
|
619
|
+
reducedBy<T>(reducerFn: (input: unknown) => T): WatchContinuation;
|
|
620
|
+
invoke(name: string): void;
|
|
618
621
|
}
|
|
619
|
-
export type
|
|
622
|
+
export type CallBackThisObject = object;
|
|
623
|
+
export type MessageCallback = (channelName: string, messageName: string, payload: unknown) => void;
|
|
624
|
+
export type SimpleMap<T> = Record<string, T>;
|
|
625
|
+
export type Type<T> = new (...args: any[]) => T;
|
|
620
626
|
|
|
621
627
|
export as namespace testsupport;
|
|
622
628
|
|
package/dist/testsupport.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
0.
|
|
2
|
+
0.5.1
|
|
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,gBAAM,aAAa;QACpB;;AAID,UAAM,6BAA6C,MAAM,IAAI,cAAa;AAE1E,UAAM,OAAe;;;;;;;;;AAgDrB,UAAM,uBAAN,MAA0B;QAIzB,YAAY,SAAoB;AAC/B,eAAK,WAAU,GAAA,SAAA,gBAAe,SAAS,SAAS;QACjD;QAEO,iBAAc;AACpB,gBAAM,WAAqB,CAAA;AAE3B,mBAAS,IAAY,GAAG,IAAI,KAAK,QAAQ,iBAAiB,EAAE,QAAQ,KAAK;AACxE,kBAAM,SAA4B,KAAK,QAAQ,iBAAiB,EAAE,CAAC;AACnE,qBAAS,KAAK,OAAO,KAAK;UAC3B;AAEA,kBAAO,GAAA,UAAA,QAAO,QAAQ;QACvB;QAEO,qBAAkB;AACxB,kBAAO,GAAA,UAAA,QAAO,KAAK,QAAQ,YAAY,KAAI,CAAE;QAC9C;QAEO,cAAW;AACjB,kBAAO,GAAA,UAAA,QAAO,KAAK,QAAQ,WAAW;QACvC;;AAID,UAAM,iBAAN,MAAoB;QAQnB,YAAY,SAAsB,OAAe,MAAY;AAC5D,eAAK,WAAU,GAAA,SAA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|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cydran/testsupport",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Testing support for Cydran",
|
|
5
5
|
"module": "dist/testsupport.js",
|
|
6
6
|
"main": "dist/testsupport.js",
|
|
@@ -12,13 +12,8 @@
|
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
|
-
"
|
|
16
|
-
"
|
|
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",
|
|
21
|
-
"build": "npm run clean && npm run transpile && npm run aggregate",
|
|
15
|
+
"validate": "npx @cydran/build validate",
|
|
16
|
+
"build": "npm run clean.dist && npm run clean.tarball && 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",
|
|
24
19
|
"clean.dist": "npx rimraf --glob dist",
|
|
@@ -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.1",
|
|
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.1",
|
|
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": "277b108cd51056b41272c5644f0020b9856f266f"
|
|
114
98
|
}
|