@cydran/testsupport 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,52 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 The Cydran Team <https://cydran.io/>
4
+
5
+ Derivative work based on Lodash 4.17.15 <https://lodash.com/license>
6
+ Copyright (c) 2019 OpenJS Foundation and other contributors <https://openjsf.org/>
7
+ ---
8
+ Derivative work based on Underscore.js
9
+ Copyright (c) 2012 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
10
+ ---
11
+ Derivative work based on docReady <https://github.com/jfriend00/docReady/blob/master/license>
12
+ Copyright (c) 2014, John Friend <https://github.com/jfriend00/docReady/>
13
+ ---
14
+ Derivative work based on Math.uuid.js <http://www.broofa.com>
15
+ Copyright (c) 2010 Robert Kieffer <https://www.broofa.com/2008/09/javascript-uuid-function/>
16
+ ---
17
+ Derivative work based on UMD <https://github.com/umdjs/umd/blob/master/LICENSE.md>
18
+ Copyright (c) 2014 the UMD contributors <https://github.com/umdjs/umd/>
19
+
20
+ This software consists of voluntary contributions made by many
21
+ individuals. For exact contribution history, see the revision history
22
+ available at https://github.com/cydran/cydran
23
+
24
+ The following license applies to all parts of this software except as
25
+ documented below:
26
+
27
+ ===
28
+
29
+ Permission is hereby granted, free of charge, to any person obtaining a copy
30
+ of this software and associated documentation files (the "Software"), to deal
31
+ in the Software without restriction, including without limitation the rights
32
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
33
+ copies of the Software, and to permit persons to whom the Software is
34
+ furnished to do so, subject to the following conditions:
35
+
36
+ The above copyright notice and this permission notice shall be included in all
37
+ copies or substantial portions of the Software.
38
+
39
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
40
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
41
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
42
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
43
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
44
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
45
+ SOFTWARE.
46
+
47
+ ====
48
+
49
+ Files located in the node_modules and vendor directories are externally
50
+ maintained libraries used by this software which have their own
51
+ licenses; we recommend you read them, as their terms may differ from the
52
+ terms above.
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ ## @cydran/testsupport
2
+
3
+ ### An unobtrusive Javascript presentation framework
4
+
5
+ This is a supplementary library to assist with testing of components built using the @cydran/cydran library.
@@ -0,0 +1,623 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ import { Matchers } from 'expect';
4
+
5
+ declare enum To {
6
+ /**
7
+ * Sends a message globally to all contexts.
8
+ */
9
+ GLOBALLY = "GLOBALLY",
10
+ /**
11
+ * Sends a message to the current context.
12
+ */
13
+ CONTEXT = "CONTEXT",
14
+ /**
15
+ * Sends a message to all descendants of the current context.
16
+ */
17
+ DESCENDANTS = "DESCENDANTS",
18
+ /**
19
+ * Sends a message to all immediate children of the current context.
20
+ */
21
+ IMMEDIATE_CHILDREN = "IMMEDIATE_CHILDREN",
22
+ /**
23
+ * Sends a message to the parent of the current context.
24
+ */
25
+ PARENT = "PARENT",
26
+ /**
27
+ * Sends a message to all parents of the current context.
28
+ */
29
+ PARENTS = "PARENTS",
30
+ /**
31
+ * Sends a message to the root object.
32
+ */
33
+ ROOT = "ROOT"
34
+ }
35
+ export declare class Harness<C extends Nestable> {
36
+ private document;
37
+ private window;
38
+ private stage;
39
+ private rootSupplier;
40
+ private actualProperties;
41
+ private initialProperties;
42
+ private root;
43
+ constructor(rootSupplier?: () => C, properties?: any);
44
+ reset(): void;
45
+ start(): Harness<C>;
46
+ stop(): Harness<C>;
47
+ getComponent(): C;
48
+ getWindow(): Window;
49
+ getDocument(): Document;
50
+ getContext(): Context;
51
+ getStage(): Stage;
52
+ registerConstant(id: string, instance: any): void;
53
+ registerPrototype(id: string, classInstance: Type<any>, resolvers?: ArgumentsResolvers): void;
54
+ registerSingleton(id: string, classInstance: Type<any>, resolvers?: ArgumentsResolvers): void;
55
+ forRole(value: string): Operations;
56
+ forLabelText(value: string): Operations;
57
+ forPlaceholderText(value: string): Operations;
58
+ forText(value: string): Operations;
59
+ forDisplayValue(value: string): Operations;
60
+ forAltText(value: string): Operations;
61
+ forTitle(value: string): Operations;
62
+ forTestId(value: string): Operations;
63
+ expectBody(): Matchers<any>;
64
+ }
65
+ export declare function isDefined(value: any): boolean;
66
+ export declare function merge<T>(sources: any[]): T;
67
+ export declare function overlay<T>(destination: T, sources: any[]): T;
68
+ export declare function requireNotNull<T>(value: T, name: string): T;
69
+ export interface ActionContinuation extends Tellable, Messagable, Watchable {
70
+ getParent(): Nestable;
71
+ getEl(): HTMLElement;
72
+ getObject<T>(id: string, ...instanceArguments: any[]): T;
73
+ getLogger(): Logger;
74
+ properties(): Properties;
75
+ getId(): string;
76
+ getPrefix(): string;
77
+ getName(): string;
78
+ scope(): Scope;
79
+ getValue<T>(): T;
80
+ isMounted(): boolean;
81
+ isConnected(): boolean;
82
+ send(messageName: string, payload?: any): SendContinuation;
83
+ onInterval(millis?: Number): IntervalContinuation;
84
+ onMessage(messageName: string): OnContinuation;
85
+ /**
86
+ * Get a {@linkcode FilterBuilder} object back to create a {@linkcode Filter} of lists in the model
87
+ * @param expression - primitive string representation expression of a JS iterable/array object
88
+ * @returns
89
+ */
90
+ createFilter(expression: string): FilterBuilder;
91
+ regions(): RegionContinuation;
92
+ tell(name: string, payload?: any): void;
93
+ forElement<E extends HTMLElement>(name: string): ElementOperations<E>;
94
+ forSeries(name: string): SeriesOperations;
95
+ forForm(name: string): FormOperations;
96
+ forForms(): FormOperations;
97
+ metadata(): MetadataContinuation;
98
+ /**
99
+ * Applies a function and synchronizes state within the UI based on effected change.
100
+ * @param fn Function to execute
101
+ * @param args Arguments
102
+ */
103
+ sync(): void;
104
+ getContext(): Context;
105
+ }
106
+ export interface Actionable<T> {
107
+ $c(): T;
108
+ }
109
+ export interface ArgumentsResolvers {
110
+ resolve(context: any, instanceArguments: any[]): any[];
111
+ postProcess(context: any, targetObject: any, params: any[]): void;
112
+ }
113
+ export interface ComponentOptions {
114
+ metadata?: SimpleMap<any>;
115
+ prefix?: string;
116
+ styles?: string;
117
+ }
118
+ export interface Context extends Sendable, Register<Context>, Tellable, Receivable {
119
+ getChild(name: string): Context;
120
+ hasChild(name: string): boolean;
121
+ addChild(name: string, initializer?: (context: Context) => void): Context;
122
+ removeChild(name: string): Context;
123
+ getObject<T>(id: string, ...instanceArguments: any[]): T;
124
+ getProperties(): MutableProperties;
125
+ getScope(): Scope;
126
+ getRoot(): Context;
127
+ isRoot(): boolean;
128
+ getParent(): Context;
129
+ registerImplicit(id: string, template: string, options?: ComponentOptions): Context;
130
+ getName(): string;
131
+ getFullName(): string;
132
+ addPreInitializer(thisObject: Object, callback: (context?: Context) => void): void;
133
+ addInitializer(thisObject: Object, callback: (context?: Context) => void): void;
134
+ addDisposer(thisObject: Object, callback: (context?: Context) => void): void;
135
+ configure(callback: (context: Context) => void, thisObject?: Object): Context;
136
+ addListener(thisObject: Object, callback: MessageCallback): void;
137
+ removeListener(thisObject: Object, callback: MessageCallback): void;
138
+ }
139
+ export interface DestinationContinuation {
140
+ withPropagation(propagation: To): void;
141
+ toSelf(): void;
142
+ }
143
+ export interface ElementOperations<E extends HTMLElement> {
144
+ get(): E;
145
+ focus(): void;
146
+ blur(): void;
147
+ }
148
+ export interface ExpectionActions {
149
+ selectedValues(): Matchers<any>;
150
+ trimmedTextContent(): Matchers<any>;
151
+ textContent(): Matchers<any>;
152
+ }
153
+ export interface Filter {
154
+ /**
155
+ * Get the resulting array of items after the filter has been applied
156
+ * @returns array of filtered objects
157
+ */
158
+ items(): any[];
159
+ /**
160
+ * Extend a {Filter filter} instance
161
+ * @returns a {FilterBuilder} object
162
+ */
163
+ extend(): FilterBuilder;
164
+ }
165
+ export interface FilterBuilder {
166
+ withPredicate(expression: string, ...parameterExpressions: string[]): FilterBuilder;
167
+ withPhase(fn: (input: any[]) => any[]): FilterBuilder;
168
+ withSimplePredicate(predicate: (index: number, value: any) => boolean): FilterBuilder;
169
+ withSort(expression: string, ...parameterExpressions: string[]): FilterBuilder;
170
+ withLimit(limit: number): FilterBuilder;
171
+ with(fn: (builder: FilterBuilder) => void): FilterBuilder;
172
+ build(): Filter;
173
+ paged(): PagedFilter;
174
+ limited(): LimitOffsetFilter;
175
+ }
176
+ export interface ForChannelContinuation {
177
+ invoke(callback: (payload: any) => void): void;
178
+ }
179
+ export interface FormOperations {
180
+ submit(): void;
181
+ requestSubmit(): void;
182
+ reset(): void;
183
+ }
184
+ export interface IntervalContinuation {
185
+ invoke(callback: () => void): void;
186
+ }
187
+ export interface IsLevelType {
188
+ /**
189
+ * Is the log level at least at "trace" level
190
+ * @returns boolean
191
+ */
192
+ isTrace(): boolean;
193
+ /**
194
+ * Is the log level at least at "debug" level
195
+ * @returns boolean
196
+ */
197
+ isDebug(): boolean;
198
+ /**
199
+ * Is the log level at least at "info" level
200
+ * @returns boolean
201
+ */
202
+ isInfo(): boolean;
203
+ /**
204
+ * Is the log level at least at "warn" level
205
+ * @returns boolean
206
+ */
207
+ isWarn(): boolean;
208
+ /**
209
+ * Is the log level at least at "error" level
210
+ * @returns boolean
211
+ */
212
+ isError(): boolean;
213
+ /**
214
+ * Is the log level at least at "fatal" level
215
+ * @returns boolean
216
+ */
217
+ isFatal(): boolean;
218
+ }
219
+ export interface LimitOffsetFilter extends Filter {
220
+ getLimit(): number;
221
+ setLimit(limit: number): void;
222
+ getOffset(): number;
223
+ setOffset(offset: number): void;
224
+ setLimitAndOffset(limit: number, offset: number): void;
225
+ }
226
+ export interface Logger extends IsLevelType {
227
+ /**
228
+ * Get the structured key name of the logger.
229
+ * @returns string
230
+ */
231
+ getKey(): string;
232
+ /**
233
+ * Get human readable label for the logger.
234
+ * @returns string
235
+ */
236
+ getLabel(): string;
237
+ /**
238
+ * Log payload at a "trace" level
239
+ * @param primaryMsg to be written out
240
+ * @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
+ */
242
+ trace(primaryMsg: string, ...moreArgs: any[]): void;
243
+ /**
244
+ * Log payload at a "debug" level
245
+ * @param primaryMsg to be written out
246
+ * @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
+ */
248
+ debug(primaryMsg: string, ...moreArgs: any[]): void;
249
+ /**
250
+ * Log payload at a "info" level
251
+ * @param primaryMsg to be written out
252
+ * @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
+ */
254
+ info(primaryMsg: string, ...moreArgs: any[]): void;
255
+ /**
256
+ * Log payload at a "warn" level
257
+ * @param primaryMsg to be written out
258
+ * @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
+ */
260
+ warn(primaryMsg: string, ...moreArgs: any[]): void;
261
+ /**
262
+ * Log payload at a "error" level
263
+ * @param primaryMsg to be written out
264
+ * @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
+ */
266
+ error(primaryMsg: string, ...moreArgs: any[]): void;
267
+ /**
268
+ * Log payload at a "fatal" level
269
+ * @param primaryMsg to be written out
270
+ * @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
+ */
272
+ fatal(primaryMsg: string, ...moreArgs: any[]): void;
273
+ /**
274
+ * Only if log at a "trace" level execute fn() to derive payload to log
275
+ * @param primaryMsgFn result of to be written out
276
+ * @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
+ */
278
+ ifTrace(primaryMsgFn: () => any, ...moreArgs: any[]): void;
279
+ /**
280
+ * Only if log at a "debug" level execute fn() to derive payload to log
281
+ * @param primaryMsgFn result of to be written out
282
+ * @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
+ */
284
+ ifDebug(primaryMsgFn: () => any, ...moreArgs: any[]): void;
285
+ /**
286
+ * Only if log at a "info" level execute fn() to derive payload to log
287
+ * @param primaryMsgFn result of to be written out
288
+ * @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
+ */
290
+ ifInfo(primaryMsgFn: () => any, ...moreArgs: any[]): void;
291
+ /**
292
+ * Only if log at a "warn" level execute fn() to derive payload to log
293
+ * @param primaryMsgFn result of to be written out
294
+ * @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
+ */
296
+ ifWarn(primaryMsgFn: () => any, ...moreArgs: any[]): void;
297
+ /**
298
+ * Only if log at a "error" level execute fn() to derive payload to log
299
+ * @param primaryMsgFn result of to be written out
300
+ * @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
+ */
302
+ ifError(primaryMsgFn: () => any, ...moreArgs: any[]): void;
303
+ /**
304
+ * Only if log at a "fatal" level execute fn() to derive payload to log
305
+ * @param primaryMsgFn result of to be written out
306
+ * @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
+ */
308
+ ifFatal(primaryMsgFn: () => any, ...moreArgs: any[]): void;
309
+ }
310
+ export interface Messagable {
311
+ send(messageName: string, payload?: any): SendContinuation;
312
+ }
313
+ export interface MetadataContinuation {
314
+ has: (name: string) => boolean;
315
+ get: (name: string) => any;
316
+ }
317
+ export interface MutableProperties extends Properties {
318
+ /**
319
+ * Set a property value
320
+ * @param key - string value
321
+ * @param value - any type of object
322
+ * @returns
323
+ */
324
+ set(key: string, value: any): MutableProperties;
325
+ /**
326
+ * Load additional properties in
327
+ * @param values - any type of object
328
+ * @returns
329
+ */
330
+ load(values: any): MutableProperties;
331
+ /**
332
+ * Remove a specific property by key
333
+ * @param key - string value
334
+ * @returns
335
+ */
336
+ remove(key: string): MutableProperties;
337
+ /**
338
+ * Clear the current properties instance object of all values
339
+ * @returns
340
+ */
341
+ clear(): MutableProperties;
342
+ /**
343
+ * Locks one or more properties.
344
+ * @param keys keys of the properties to lock
345
+ */
346
+ lock(...keys: string[]): MutableProperties;
347
+ /**
348
+ * Unlocks one or more properties.
349
+ * @param keys keys of the properties to unlock
350
+ */
351
+ unlock(...keys: string[]): MutableProperties;
352
+ /**
353
+ * Locks one or more properties.
354
+ * @param keys keys of the properties to lock
355
+ */
356
+ pin(...keys: string[]): MutableProperties;
357
+ /**
358
+ * Unlocks one or more properties.
359
+ * @param keys keys of the properties to unlock
360
+ */
361
+ unpin(...keys: string[]): MutableProperties;
362
+ /**
363
+ * Modifies a property by applying a function to the current value to derive a new value for the property.
364
+ * @param key key of the property to modify
365
+ * @param modifierFn Function with which to modify the property
366
+ */
367
+ modify<T>(key: string, modifierFn: (value: T) => T): MutableProperties;
368
+ mirror(source: Properties): MutableProperties;
369
+ }
370
+ export interface Nestable extends Actionable<ActionContinuation> {
371
+ onMount(): void;
372
+ onUnmount(): void;
373
+ onRemount(): void;
374
+ }
375
+ export interface OnContinuation {
376
+ invoke(callback: (payload: any) => void): void;
377
+ forChannel(channelName: string): ForChannelContinuation;
378
+ }
379
+ export interface Operations {
380
+ get<E extends HTMLElement>(options?: any): E;
381
+ query(options?: any): HTMLElement;
382
+ find(options?: any): HTMLElement;
383
+ getAll(options?: any): HTMLElement[];
384
+ queryAll(options?: any): HTMLElement[];
385
+ findAll(options?: any): HTMLElement[];
386
+ expect(options?: any): ExpectionActions;
387
+ appendText(text: string, options?: any): void;
388
+ replaceText(text: string, options?: any): void;
389
+ selectIndex(index: number, options?: any): void;
390
+ selectIndexes(indexes: number[], options?: any): void;
391
+ setCheckedState(options?: any): void;
392
+ }
393
+ export interface PagedFilter extends Filter {
394
+ getPageSize(): number;
395
+ setPageSize(size: number): void;
396
+ getTotalPages(): number;
397
+ getPage(): number;
398
+ setPage(page: number): void;
399
+ toPrevious(): void;
400
+ toNext(): void;
401
+ toStart(): void;
402
+ toEnd(): void;
403
+ isAtBeginning(): boolean;
404
+ isAtEnd(): boolean;
405
+ isMoreBefore(): boolean;
406
+ isMoreAfter(): boolean;
407
+ }
408
+ export interface Properties {
409
+ /**
410
+ * Add an observer for all property changes.
411
+ * @param thisObject Object used as this when calling the callback
412
+ * @param callback - callback function to be called when any property is changed
413
+ */
414
+ addObserver(thisObject: Object, callback: (key: string, value: any) => void): void;
415
+ /**
416
+ * Remove an observer that listened for all property changes.
417
+ * @param thisObject Object used as this when calling the callback
418
+ * @param callback callback function to be removed
419
+ */
420
+ removeObserver(thisObject: Object, callback: (key: string, value: any) => void): void;
421
+ /**
422
+ * Add an observer for a specific property changes, or changes of more general property when the preferred is unavailable.
423
+ * @param thisObject Object used as this when calling the callback
424
+ * @param callback callback function to be called when the specific property is changed
425
+ * @param preferredKey Preferred property key to observe
426
+ * @param prefix Property key prefix for keys which should be included for consideration
427
+ */
428
+ addFallbackObserver(thisObject: Object, callback: (key: string, value: any) => void, preferredKey: string, prefix?: string): void;
429
+ /**
430
+ * Remove an observer for a specific property changes, or changes of more general property when the preferred is unavailable.
431
+ * @param thisObject Object used as this when calling the callback
432
+ * @param callback callback function to be removed
433
+ */
434
+ removeFallbackObserver(thisObject: Object, callback: (key: string, value: any) => void): void;
435
+ /**
436
+ * Add an observer for specific property.
437
+ * @param key Specific property key
438
+ * @param thisObject Object used as this when calling the callback
439
+ * @param callback callback function to be called when the specific property is changed
440
+ */
441
+ addPropertyObserver(key: string, thisObject: Object, callback: (value: any) => void): void;
442
+ /**
443
+ * Remove an observer for specific property.
444
+ * @param key Specific property key
445
+ * @param thisObject Object used as this when calling the callback
446
+ * @param callback callback function to remove
447
+ */
448
+ removePropertyObserver(key: string, thisObject: Object, callback: (value: any) => void): void;
449
+ snapshot(): MutableProperties;
450
+ /**
451
+ * Get all the keys present in the properties object
452
+ * @returns - array of string values
453
+ */
454
+ keys(): string[];
455
+ /**
456
+ * Get the defined property object
457
+ * @param key - property key value
458
+ * @returns - typed property object
459
+ */
460
+ get<T>(key: string): T;
461
+ /**
462
+ * Get the defined property object or a fallback property object if the preferred is unavailable
463
+ * @param preferredKey - property key value
464
+ * @param prefix - prefix to limit candidate keys
465
+ * @returns - typed property object
466
+ */
467
+ getWithFallback<T>(preferredKey: string, prefix?: string): T;
468
+ /**
469
+ * Indicates whether a property is defined.
470
+ * @param key Property key
471
+ */
472
+ includes(key: string): boolean;
473
+ /**
474
+ * Get a mutable inheriting child {@link Properties} object
475
+ * @returns - properties object
476
+ */
477
+ extend(): MutableProperties;
478
+ /**
479
+ * Is the property indexed at the "key" defined
480
+ * @param key - string value
481
+ * @returns - property existence
482
+ */
483
+ isDefined(key: string): boolean;
484
+ /**
485
+ * Can the defined property value identified by key be expressed as "truthy"
486
+ * @param key - string value
487
+ * @returns - is truthy
488
+ */
489
+ isTruthy(key: string): boolean;
490
+ /**
491
+ * Can the defined property value identified by key be expressed as "falsy"
492
+ * @param key - string value
493
+ * @returns - is truthy
494
+ */
495
+ isFalsy(key: string): boolean;
496
+ /**
497
+ * Indicates whether a specific property is locked.
498
+ * @param key - string value
499
+ */
500
+ isLocked(key: string): boolean;
501
+ /**
502
+ * Indicates whether a specific property is pinned.
503
+ * @param key - string value
504
+ */
505
+ isPinned(key: string): boolean;
506
+ /**
507
+ * Get the string representation of the property indicated by the key
508
+ * @param key - string value
509
+ * @returns - string value representation
510
+ */
511
+ getAsString(key: string): string;
512
+ }
513
+ export interface Receivable {
514
+ /**
515
+ * Sends a message to a specific object.
516
+ * @param channelName The name of the channel to send the message to.
517
+ * @param messageName The name of the message to send.
518
+ * @param payload The optional payload to include with the message.
519
+ */
520
+ message(channelName: string, messageName: string, payload?: any): void;
521
+ }
522
+ export interface RegionContinuation {
523
+ /**
524
+ * Component has a {@link Region}
525
+ * @returns boolean - true | false
526
+ */
527
+ has(name: string): boolean;
528
+ /**
529
+ * Get a child component from a region.
530
+ * @param name - string name value of the child {@link Component}
531
+ * @returns Component instance, or null
532
+ */
533
+ get<N extends Nestable>(name: string): N;
534
+ /**
535
+ * Set a child component into a region.
536
+ * @param name - string name value of the child {@link Component}
537
+ * @param component - the {@link Component} reference
538
+ */
539
+ set(name: string, component: Nestable): void;
540
+ setByObjectId(name: string, componentName: string, defaultComponentName?: string): void;
541
+ }
542
+ export interface Register<R> extends Releasable {
543
+ registerConstant(id: string, instance: any): R;
544
+ registerPrototype(id: string, classInstance: Type<any>, resolvers?: ArgumentsResolvers, localResolution?: boolean): R;
545
+ registerPrototypeWithFactory(id: string, factoryFn: () => any, resolvers?: ArgumentsResolvers, localResolution?: boolean): R;
546
+ registerSingleton(id: string, classInstance: Type<any>, resolvers?: ArgumentsResolvers, localResolution?: boolean): R;
547
+ registerSingletonWithFactory(id: string, factoryFn: () => any, resolvers?: ArgumentsResolvers, localResolution?: boolean): R;
548
+ hasRegistration(id: string): boolean;
549
+ expose(id: string): R;
550
+ }
551
+ export interface Releasable {
552
+ $release(): void;
553
+ }
554
+ export interface Scope {
555
+ add(name: string, item: any): Scope;
556
+ remove(name: string): Scope;
557
+ extend(): Scope;
558
+ }
559
+ export interface SendContinuation extends DestinationContinuation {
560
+ onChannel(channelName: string): DestinationContinuation;
561
+ }
562
+ /**
563
+ * Represents an object that can send messages to other objects.
564
+ */
565
+ export interface Sendable {
566
+ /**
567
+ * Sends a message with a specific propagation.
568
+ * @param propagation Propagation of the message
569
+ * @param channelName The name of the channel to send the message to
570
+ * @param messageName The name of the message to send
571
+ * @param payload The optional payload to include with the message
572
+ * @param startFrom The optional path to the context start the traversal from
573
+ */
574
+ send(propagation: To, channelName: string, messageName: string, payload?: any, startFrom?: string): void;
575
+ }
576
+ export interface SeriesOperations {
577
+ getAt<N extends Nestable>(index: number): N;
578
+ replace(oldComponent: Nestable, newComponent: Nestable): void;
579
+ replaceAt(index: number, component: Nestable): void;
580
+ remove(component: Nestable): void;
581
+ removeAt(index: number): void;
582
+ insertBefore(index: number, component: Nestable): void;
583
+ insertAfter(index: number, component: Nestable): void;
584
+ insertFirst(component: Nestable): void;
585
+ insertLast(component: Nestable): void;
586
+ hasComponents(): boolean;
587
+ contains(component: Nestable): boolean;
588
+ isEmpty(): boolean;
589
+ clear(): void;
590
+ }
591
+ export interface SimpleMap<T> {
592
+ [key: string]: T;
593
+ }
594
+ export interface Stage extends Releasable {
595
+ getContext(): Context;
596
+ before(): SeriesOperations;
597
+ after(): SeriesOperations;
598
+ start(): Stage;
599
+ setComponent(component: Nestable): Stage;
600
+ setComponentByObjectId(componentName: string, defaultComponentName?: string): Stage;
601
+ isStarted(): boolean;
602
+ addInitializer(thisObject: Object, callback: (stage: Stage) => void): Stage;
603
+ }
604
+ export interface Tellable {
605
+ tell(name: string, payload?: any): void;
606
+ }
607
+ export interface Type<T> extends Function {
608
+ new (...args: any[]): T;
609
+ }
610
+ export interface Watchable {
611
+ onExpressionValueChange<T>(expression: string, callback: (previous: T, current: T) => void, reducerFn?: (input: any) => T, thisObject?: Object): void;
612
+ /**
613
+ * Evaluates an expression.
614
+ * @param expression Expression to evaluate.
615
+ */
616
+ evaluate<T>(expression: string): T;
617
+ getWatchScope(): any;
618
+ }
619
+ export type MessageCallback = (channelName: string, messageName: string, payload: any) => void;
620
+
621
+ export as namespace testsupport;
622
+
623
+ export {};
@@ -0,0 +1,301 @@
1
+ /*
2
+ 0.4.0
3
+ ---
4
+ Cydran <http://cydran.io/>
5
+ Copyright (c) 2018 The Cydran Team and other contributors <http://cydran.io/>
6
+ Released under MIT license <http://cydran.io/license>
7
+ ---
8
+ Derivative work based on Lodash 4.17.15 <https://lodash.com/license>
9
+ Copyright (c) 2019 OpenJS Foundation and other contributors <https://openjsf.org/>
10
+ ---
11
+ Derivative work based on Underscore.js
12
+ Copyright (c) 2012 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
13
+ ---
14
+ Derivative work based on docReady <https://github.com/jfriend00/docReady/blob/master/license>
15
+ Copyright (c) 2014, John Friend <https://github.com/jfriend00/docReady/>
16
+ ---
17
+ Derivative work based on Math.uuid.js <http://www.broofa.com>
18
+ Copyright (c) 2010 Robert Kieffer <https://www.broofa.com/2008/09/javascript-uuid-function/>
19
+ ---
20
+ Derivative work based on UMD <https://github.com/umdjs/umd/blob/master/LICENSE.md>
21
+ Copyright (c) 2014 the UMD contributors <https://github.com/umdjs/umd/>
22
+
23
+ */
24
+ "use strict";
25
+ var testsupport = (() => {
26
+ var __getOwnPropNames = Object.getOwnPropertyNames;
27
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
28
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
29
+ }) : x)(function(x) {
30
+ if (typeof require !== "undefined") return require.apply(this, arguments);
31
+ throw Error('Dynamic require of "' + x + '" is not supported');
32
+ });
33
+ var __commonJS = (cb, mod) => function __require2() {
34
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
35
+ };
36
+
37
+ // dist/src/harness/Harness.js
38
+ var require_Harness = __commonJS({
39
+ "dist/src/harness/Harness.js"(exports) {
40
+ "use strict";
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var jsdom_1 = __require("jsdom");
43
+ var cydran_1 = __require("@cydran/cydran");
44
+ var dom_1 = __require("@testing-library/dom");
45
+ var globals_1 = __require("@jest/globals");
46
+ var TestComponent = class extends cydran_1.Component {
47
+ constructor() {
48
+ super("<div></div>");
49
+ }
50
+ };
51
+ var DEFAULT_COMPONENT_SUPPLIER = () => new TestComponent();
52
+ var HTML = `<!doctype html>
53
+ <html lang="en">
54
+ <head>
55
+ <title>Cydran Test Harness</title>
56
+ </head>
57
+ <body>
58
+ <!-- Stage Content -->
59
+ </body>
60
+ </html>`;
61
+ var ExpectionActionsImpl = class {
62
+ constructor(element) {
63
+ this.element = (0, cydran_1.requireNotNull)(element, "element");
64
+ }
65
+ selectedValues() {
66
+ const selected = [];
67
+ for (let i = 0; i < this.element["selectedOptions"].length; i++) {
68
+ const option = this.element["selectedOptions"][i];
69
+ selected.push(option.value);
70
+ }
71
+ return (0, globals_1.expect)(selected);
72
+ }
73
+ trimmedTextContent() {
74
+ return (0, globals_1.expect)(this.element.textContent.trim());
75
+ }
76
+ textContent() {
77
+ return (0, globals_1.expect)(this.element.textContent);
78
+ }
79
+ };
80
+ var OperationsImpl = class {
81
+ constructor(element, value, type) {
82
+ this.element = (0, cydran_1.requireNotNull)(element, "element");
83
+ this.value = (0, cydran_1.requireNotNull)(value, "value");
84
+ this.type = (0, cydran_1.requireNotNull)(type, "type");
85
+ }
86
+ get(options) {
87
+ return this.execute("get", options);
88
+ }
89
+ query(options) {
90
+ return this.execute("query", options);
91
+ }
92
+ find(options) {
93
+ return this.execute("find", options);
94
+ }
95
+ getAll(options) {
96
+ return this.execute("getAll", options);
97
+ }
98
+ queryAll(options) {
99
+ return this.execute("queryAll", options);
100
+ }
101
+ findAll(options) {
102
+ return this.execute("findAll", options);
103
+ }
104
+ expect(options) {
105
+ const element = this.get(options);
106
+ return new ExpectionActionsImpl(element);
107
+ }
108
+ appendText(text, options) {
109
+ const element = this.get(options);
110
+ element.value = element.value + text;
111
+ dom_1.fireEvent.input(element);
112
+ }
113
+ replaceText(text, options) {
114
+ const element = this.get(options);
115
+ element.value = text;
116
+ dom_1.fireEvent.input(element);
117
+ }
118
+ selectIndex(index, options) {
119
+ const element = this.get(options);
120
+ element.selectedIndex = index;
121
+ dom_1.fireEvent.change(element);
122
+ }
123
+ selectIndexes(indexes, options) {
124
+ const element = this.get(options);
125
+ for (let i = 0; i < element.options.length; i++) {
126
+ const option = element.options[i];
127
+ option.selected = false;
128
+ }
129
+ for (let i = 0; i < indexes.length; i++) {
130
+ const index = indexes[i];
131
+ const option = element.options[index];
132
+ option.selected = true;
133
+ }
134
+ dom_1.fireEvent.change(element);
135
+ }
136
+ setCheckedState(value, options) {
137
+ const element = this.get(options);
138
+ element.checked = value;
139
+ dom_1.fireEvent.input(element);
140
+ }
141
+ execute(name, options) {
142
+ const methodName = name + "By" + this.type;
143
+ return dom_1.queries[methodName](this.element, this.value, options);
144
+ }
145
+ };
146
+ var Harness = class {
147
+ constructor(rootSupplier = DEFAULT_COMPONENT_SUPPLIER, properties) {
148
+ this.rootSupplier = (0, cydran_1.requireNotNull)(rootSupplier, "rootSupplier");
149
+ this.actualProperties = (0, cydran_1.isDefined)(properties) ? properties : {};
150
+ this.reset();
151
+ }
152
+ reset() {
153
+ this.stop();
154
+ this.window = new jsdom_1.JSDOM(HTML).window;
155
+ this.document = this.window.document;
156
+ const defaultProperties = {
157
+ [cydran_1.PropertyKeys.CYDRAN_STARTUP_SYNCHRONOUS]: true,
158
+ [cydran_1.PropertyKeys.CYDRAN_LOG_LEVEL]: "WARN",
159
+ [cydran_1.PropertyKeys.CYDRAN_OVERRIDE_WINDOW]: this.window
160
+ };
161
+ this.initialProperties = (0, cydran_1.merge)([defaultProperties, this.actualProperties]);
162
+ this.stage = (0, cydran_1.create)("body", this.initialProperties);
163
+ this.stage.addInitializer({}, (stage) => {
164
+ this.root = this.rootSupplier();
165
+ stage.setComponent(this.root);
166
+ });
167
+ }
168
+ start() {
169
+ this.stage.start();
170
+ return this;
171
+ }
172
+ stop() {
173
+ if ((0, cydran_1.isDefined)(this.stage) && this.stage.isStarted()) {
174
+ this.stage.$release();
175
+ }
176
+ return this;
177
+ }
178
+ getComponent() {
179
+ return this.root;
180
+ }
181
+ getWindow() {
182
+ return this.window;
183
+ }
184
+ getDocument() {
185
+ return this.document;
186
+ }
187
+ getContext() {
188
+ return this.stage.getContext();
189
+ }
190
+ getStage() {
191
+ return this.stage;
192
+ }
193
+ registerConstant(id, instance) {
194
+ this.stage.getContext().registerConstant(id, instance);
195
+ }
196
+ registerPrototype(id, classInstance, resolvers) {
197
+ this.stage.getContext().registerPrototype(id, classInstance, resolvers);
198
+ }
199
+ registerSingleton(id, classInstance, resolvers) {
200
+ this.stage.getContext().registerSingleton(id, classInstance, resolvers);
201
+ }
202
+ forRole(value) {
203
+ return new OperationsImpl(this.document.documentElement, value, "Role");
204
+ }
205
+ forLabelText(value) {
206
+ return new OperationsImpl(this.document.documentElement, value, "LabelText");
207
+ }
208
+ forPlaceholderText(value) {
209
+ return new OperationsImpl(this.document.documentElement, value, "PlaceholderText");
210
+ }
211
+ forText(value) {
212
+ return new OperationsImpl(this.document.documentElement, value, "Text");
213
+ }
214
+ forDisplayValue(value) {
215
+ return new OperationsImpl(this.document.documentElement, value, "DisplayValue");
216
+ }
217
+ forAltText(value) {
218
+ return new OperationsImpl(this.document.documentElement, value, "AltText");
219
+ }
220
+ forTitle(value) {
221
+ return new OperationsImpl(this.document.documentElement, value, "Title");
222
+ }
223
+ forTestId(value) {
224
+ return new OperationsImpl(this.document.documentElement, value, "TestId");
225
+ }
226
+ expectBody() {
227
+ return (0, globals_1.expect)(this.document.body.innerHTML);
228
+ }
229
+ };
230
+ exports.default = Harness;
231
+ }
232
+ });
233
+
234
+ // dist/src/index.js
235
+ var require_src = __commonJS({
236
+ "dist/src/index.js"(exports) {
237
+ var __importDefault = exports && exports.__importDefault || function(mod) {
238
+ return mod && mod.__esModule ? mod : { "default": mod };
239
+ };
240
+ Object.defineProperty(exports, "__esModule", { value: true });
241
+ exports.Harness = void 0;
242
+ exports.overlay = overlay;
243
+ exports.merge = merge;
244
+ exports.requireNotNull = requireNotNull;
245
+ exports.isDefined = isDefined;
246
+ var Harness_1 = __importDefault(require_Harness());
247
+ exports.Harness = Harness_1.default;
248
+ function isDefined(value) {
249
+ return value !== null && value !== void 0;
250
+ }
251
+ function requireNotNull(value, name) {
252
+ if (value === null || value === void 0) {
253
+ throw new Error(`${name} shall not be null`);
254
+ }
255
+ return value;
256
+ }
257
+ function merge(sources) {
258
+ requireNotNull(sources, "sources");
259
+ return overlay({}, sources);
260
+ }
261
+ function overlay(destination, sources) {
262
+ requireNotNull(destination, "destination");
263
+ requireNotNull(sources, "sources");
264
+ for (const source of sources) {
265
+ if (!isDefined(source)) {
266
+ continue;
267
+ }
268
+ for (const name in source) {
269
+ if (!source.hasOwnProperty(name)) {
270
+ continue;
271
+ }
272
+ if (!isDefined(source[name])) {
273
+ continue;
274
+ }
275
+ destination[name] = source[name];
276
+ }
277
+ }
278
+ return destination;
279
+ }
280
+ }
281
+ });
282
+ return require_src();
283
+ })();
284
+ ((root, factory, cydranObject) => {
285
+ if (typeof define === 'function' && define.amd) {
286
+ // AMD. Register as an anonymous module.
287
+ define(['exports'], function(exports) {
288
+ factory((root.commonJsStrictGlobal = exports), cydranObject);
289
+ });
290
+ } else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') {
291
+ // CommonJS
292
+ factory(exports, cydranObject);
293
+ } else {
294
+ // Browser globals
295
+ factory((root.commonJsStrictGlobal = {}), cydranObject);
296
+ }
297
+ })(typeof self !== 'undefined' ? self : this, function(exports, c) {
298
+ c.overlay(exports, [c]);
299
+ }, testsupport);
300
+
301
+ //# sourceMappingURL=testsupport.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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,6BAAwC,MAAM,IAAI,cAAa;AAErE,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;AAG3B,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;QAQn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7B,iBAAO,IAAI,eAAe,KAAK,SAAS,iBAAiB,OAAO,QAAQ;QACzE;QAEO,aAAU;AAChB,kBAAO,GAAA,UAAA,QAAO,KAAK,SAAS,KAAK,SAAS;QAC3C;;AAID,cAAA,UAAe;;;;;;;;;;;;AC9QL,cAAA,UAAA;AAAS,cAAA,QAAA;AAAO,cAAA,iBAAA;AAAgB,cAAA,YAAA;AA9C1C,UAAA,YAAA,gBAAA,iBAAA;AA8CC,cAAA,UA9CM,UAAA;AAEP,eAAS,UAAU,OAAU;AAC5B,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,SAAc;AAC/B,uBAAe,SAAS,SAAS;AAEjC,eAAO,QAAQ,CAAA,GAAS,OAAO;MAChC;AAEA,eAAS,QAAW,aAAgB,SAAc;AACjD,uBAAe,aAAa,aAAa;AACzC,uBAAe,SAAS,SAAS;AAEjC,mBAAW,UAAU,SAAS;AAC7B,cAAI,CAAC,UAAU,MAAM,GAAG;AACvB;UACD;AAEA,qBAAW,QAAQ,QAAQ;AAC1B,gBAAI,CAAC,OAAO,eAAe,IAAI,GAAG;AACjC;YACD;AAEA,gBAAI,CAAC,UAAU,OAAO,IAAI,CAAC,GAAG;AAC7B;YACD;AAEA,wBAAY,IAAI,IAAI,OAAO,IAAI;UAChC;QACD;AAEA,eAAO;MACR;;;",
6
+ "names": []
7
+ }
package/package.json ADDED
@@ -0,0 +1,114 @@
1
+ {
2
+ "name": "@cydran/testsupport",
3
+ "version": "0.4.0",
4
+ "description": "Testing support for Cydran",
5
+ "module": "dist/testsupport.js",
6
+ "main": "dist/testsupport.js",
7
+ "typings": "dist/testsupport.d.ts",
8
+ "browser": {
9
+ "test": "dist/testsupport.js"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "scripts": {
15
+ "lint": "npm run lint.src && npm run lint.packageJson",
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",
21
+ "build": "npm run clean && npm run transpile && npm run aggregate",
22
+ "build.all": "npm run build.release && npm run docs",
23
+ "clean": "npm run clean.dist && npm run clean.coverage && npm run clean.tarball",
24
+ "clean.dist": "npx rimraf --glob dist",
25
+ "clean.coverage": "npx rimraf --glob coverage",
26
+ "clean.tarball": "npx rimraf --glob *.tgz",
27
+ "transpile": "npx tsc --project tsconfig.json",
28
+ "aggregate": "npm run aggregate.dts && npm run aggregate.js && npm run aggregate.clean",
29
+ "aggregate.dts": "npx dts-bundle-generator --config dts-bundle-generator-config.json",
30
+ "aggregate.js": "node esbuild.js",
31
+ "aggregate.clean": "npx rimraf --glob dist/src",
32
+ "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
+ "docs": "npx rimraf --glob docs && npx typedoc --options ./typedoc.json --tsconfig ./tsconfig.json ./src",
40
+ "docsification": "docsify --help"
41
+ },
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "https://github.com/cydran/cydran.git"
45
+ },
46
+ "keywords": [
47
+ "MVVM",
48
+ "components",
49
+ "component",
50
+ "framework"
51
+ ],
52
+ "contributors": [
53
+ {
54
+ "name": "Matthew Werny",
55
+ "url": "https://github.com/matthewwerny"
56
+ },
57
+ {
58
+ "name": "Burk Price",
59
+ "url": "https://github.com/evilchia"
60
+ }
61
+ ],
62
+ "author": "The Cydran team",
63
+ "license": "MIT",
64
+ "bugs": {
65
+ "url": "https://github.com/cydran/cydran/issues"
66
+ },
67
+ "homepage": "https://github.com/cydran/cydran",
68
+ "devDependencies": {
69
+ "@babel/cli": "7.25.6",
70
+ "@babel/core": "7.25.2",
71
+ "@babel/plugin-transform-modules-umd": "7.24.7",
72
+ "@babel/preset-env": "7.25.4",
73
+ "@babel/preset-typescript": "7.24.7",
74
+ "@cydran/build": "^0.4.0",
75
+ "@types/lodash": "4.17.7",
76
+ "@types/node": "22.5.4",
77
+ "@typescript-eslint/eslint-plugin": "8.5.0",
78
+ "@typescript-eslint/parser": "8.5.0",
79
+ "babel-preset-es2015": "6.24.1",
80
+ "cross-env": "7.0.3",
81
+ "dependency-cruiser": "16.4.1",
82
+ "docpress": "0.8.2",
83
+ "dts-bundle-generator": "9.5.1",
84
+ "esbuild": "0.23.1",
85
+ "eslint": "8.57.0",
86
+ "expose-gc": "1.0.0",
87
+ "fs-extra": "11.2.0",
88
+ "npm-package-json-lint": "8.0.0",
89
+ "requirejs": "2.3.7",
90
+ "rimraf": "6.0.1",
91
+ "source-map-support": "0.5.21",
92
+ "ts-mockito": "2.6.1",
93
+ "ts-node": "10.9.2",
94
+ "typedoc": "0.26.7",
95
+ "typescript": "5.6.2"
96
+ },
97
+ "dependencies": {
98
+ "@cydran/cydran": "^0.4.0",
99
+ "@jest/globals": "29.7.0",
100
+ "@testing-library/dom": "10.4.0",
101
+ "@testing-library/jest-dom": "6.5.0",
102
+ "@types/expect": "24.3.0",
103
+ "@types/jest": "29.5.13",
104
+ "@types/jsdom": "21.1.7",
105
+ "expect": "29.7.0",
106
+ "jest": "29.7.0",
107
+ "jest-environment-jsdom": "29.7.0",
108
+ "jsdom": "25.0.0"
109
+ },
110
+ "docpress": {
111
+ "dist": "dist/docs"
112
+ },
113
+ "gitHead": "d7bbdb33bda711fb25a0f73419d72404b4530f13"
114
+ }