diff options
author | Benjamin Gruenbaum <inglor@gmail.com> | 2020-11-02 19:42:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-02 18:42:22 +0100 |
commit | a8ca9fe7bb93d031af865ffcf45fb265395f1e1b (patch) | |
tree | 8f6becb0e83e126fa0c2e93005e579eac1630280 /cli/tests | |
parent | 0e5c8c03ac9290e752d15c23e107bfbd97d03c72 (diff) |
test(op_crates/web): add EventTarget tests (#8205)
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/unit/event_target_test.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/cli/tests/unit/event_target_test.ts b/cli/tests/unit/event_target_test.ts index 10293a0e9..34271b470 100644 --- a/cli/tests/unit/event_target_test.ts +++ b/cli/tests/unit/event_target_test.ts @@ -223,3 +223,23 @@ unitTest( assertEquals(callCount, 2); }, ); +unitTest(function eventTargetDispatchShouldSetTargetNoListener(): void { + const target = new EventTarget(); + const event = new Event("foo"); + assertEquals(event.target, null); + target.dispatchEvent(event); + assertEquals(event.target, target); +}); + +unitTest(function eventTargetDispatchShouldSetTargetInListener(): void { + const target = new EventTarget(); + const event = new Event("foo"); + assertEquals(event.target, null); + let called = false; + target.addEventListener("foo", (e) => { + assertEquals(e.target, target); + called = true; + }); + target.dispatchEvent(event); + assertEquals(called, true); +}); |