summaryrefslogtreecommitdiff
path: root/cli/tests/unit/event_test.ts
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2021-06-24 09:43:41 -0400
committerGitHub <noreply@github.com>2021-06-24 09:43:41 -0400
commita2067ec46d410b691229b6fcaa12ff5f1dd223f3 (patch)
tree76cb85186de7db5801eeaab6479c42fe01127586 /cli/tests/unit/event_test.ts
parent4b3845b998ae2f7cd6e02625b4cfc3613878ceb2 (diff)
fix(inspect): eliminate panic inspecting event classes (#10979)
Diffstat (limited to 'cli/tests/unit/event_test.ts')
-rw-r--r--cli/tests/unit/event_test.ts34
1 files changed, 33 insertions, 1 deletions
diff --git a/cli/tests/unit/event_test.ts b/cli/tests/unit/event_test.ts
index 9eb90fa36..9e5155964 100644
--- a/cli/tests/unit/event_test.ts
+++ b/cli/tests/unit/event_test.ts
@@ -1,5 +1,10 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
-import { assert, assertEquals, unitTest } from "./test_util.ts";
+import {
+ assert,
+ assertEquals,
+ assertStringIncludes,
+ unitTest,
+} from "./test_util.ts";
unitTest(function eventInitializedWithType(): void {
const type = "click";
@@ -127,3 +132,30 @@ unitTest(function eventInspectOutput(): void {
assertEquals(Deno.inspect(event), outputProvider(event));
}
});
+
+unitTest(function inspectEvent(): void {
+ // has a customInspect implementation that previously would throw on a getter
+ assertEquals(
+ Deno.inspect(Event.prototype),
+ `Event {
+ bubbles: [Getter/Setter],
+ cancelable: [Getter/Setter],
+ composed: [Getter/Setter],
+ currentTarget: [Getter/Setter],
+ defaultPrevented: [Getter/Setter],
+ eventPhase: [Getter/Setter],
+ srcElement: [Getter/Setter],
+ target: [Getter/Setter],
+ returnValue: [Getter/Setter],
+ timeStamp: [Getter/Setter],
+ type: [Getter/Setter]
+}`,
+ );
+
+ // ensure this still works
+ assertStringIncludes(
+ Deno.inspect(new Event("test")),
+ // check a substring because one property is a timestamp
+ `Event {\n bubbles: false,\n cancelable: false,`,
+ );
+});