1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-05 09:04:41 -05:00
denoland-deno/cli/tests/unit/custom_event_test.ts

28 lines
872 B
TypeScript
Raw Normal View History

2022-01-20 02:10:16 -05:00
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
import { assertEquals } from "./test_util.ts";
2019-01-23 07:20:53 -05:00
Deno.test(function customEventInitializedWithDetail() {
2019-01-23 07:20:53 -05:00
const type = "touchstart";
const detail = { message: "hello" };
const customEventInit = {
2019-01-23 07:20:53 -05:00
bubbles: true,
cancelable: true,
detail,
} as CustomEventInit;
const event = new CustomEvent(type, customEventInit);
2019-01-23 07:20:53 -05:00
assertEquals(event.bubbles, true);
assertEquals(event.cancelable, true);
assertEquals(event.currentTarget, null);
assertEquals(event.detail, detail);
assertEquals(event.isTrusted, false);
assertEquals(event.target, null);
assertEquals(event.type, type);
2019-01-23 07:20:53 -05:00
});
Deno.test(function toStringShouldBeWebCompatibility() {
const type = "touchstart";
const event = new CustomEvent(type, {});
assertEquals(event.toString(), "[object CustomEvent]");
});