-
Notifications
You must be signed in to change notification settings - Fork 20
/
event_handlers.spec.ts
36 lines (29 loc) · 1.03 KB
/
event_handlers.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { useResetDOM, useResetModules, useIVI } from "ivi-jest";
useResetDOM();
useResetModules();
const ivi = useIVI();
describe(`Event Handler`, () => {
function handler(ev: any): void {
// Event handler...
}
test(`event dispatcher should be assigned`, () => {
const h = ivi.onClick(handler);
expect(h.d.s).toBe(ivi.CLICK_EVENT);
});
test(`event handler should be assigned`, () => {
const h = ivi.onClick(handler);
expect(h.h).toBe(handler);
});
test(`event handler shouldn't have capture flag when capture arg is undefined`, () => {
const h = ivi.onClick(handler);
expect(h.d.f & ivi.EventHandlerFlags.Capture).toBeFalsy();
});
test(`event handler shouldn't have capture flag when capture arg is false`, () => {
const h = ivi.onClick(handler, false);
expect(h.d.f & ivi.EventHandlerFlags.Capture).toBeFalsy();
});
test(`event handler should have capture flag`, () => {
const h = ivi.onClick(handler, true);
expect(h.d.f & ivi.EventHandlerFlags.Capture).toBeTruthy();
});
});