Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.

Commit 52827a0

Browse files
Added test utility from SKY UX (#382)
* Added test utility from SKY UX * Separated event options into separate file
1 parent 4688d33 commit 52827a0

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

runtime/testing/browser/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from './matchers';
22
export * from './test-module';
3+
export * from './test-utility';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export interface SkyAppTestUtilityDomEventOptions {
2+
bubbles?: boolean;
3+
cancelable?: boolean;
4+
}
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { SkyAppTestUtilityDomEventOptions } from './test-utility-dom-event-options';
2+
3+
export class SkyAppTestUtility {
4+
public static fireDomEvent(
5+
element: EventTarget,
6+
eventName: string,
7+
options?: SkyAppTestUtilityDomEventOptions
8+
) {
9+
const defaults = { bubbles: true, cancelable: true };
10+
const { bubbles, cancelable } = Object.assign({}, defaults, options);
11+
12+
const event = document.createEvent('CustomEvent');
13+
event.initEvent(eventName, bubbles, cancelable);
14+
15+
element.dispatchEvent(event);
16+
}
17+
}

0 commit comments

Comments
 (0)