2023-01-02 16:00:42 -05:00
|
|
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
2021-11-23 11:45:18 -05:00
|
|
|
import { assertEquals } from "./test_util.ts";
|
2019-01-23 07:20:53 -05:00
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function customEventInitializedWithDetail() {
|
2019-01-23 07:20:53 -05:00
|
|
|
const type = "touchstart";
|
|
|
|
const detail = { message: "hello" };
|
2019-09-17 12:17:12 -04:00
|
|
|
const customEventInit = {
|
2019-01-23 07:20:53 -05:00
|
|
|
bubbles: true,
|
|
|
|
cancelable: true,
|
2020-03-28 13:03:49 -04:00
|
|
|
detail,
|
2019-09-17 12:17:12 -04:00
|
|
|
} as CustomEventInit;
|
|
|
|
const event = new CustomEvent(type, customEventInit);
|
2019-01-23 07:20:53 -05:00
|
|
|
|
2019-03-06 20:48:46 -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
|
|
|
});
|
2019-04-03 08:41:05 -04:00
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function toStringShouldBeWebCompatibility() {
|
2019-04-03 08:41:05 -04:00
|
|
|
const type = "touchstart";
|
|
|
|
const event = new CustomEvent(type, {});
|
|
|
|
assertEquals(event.toString(), "[object CustomEvent]");
|
|
|
|
});
|