-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathevent.test.ts
57 lines (48 loc) · 1.63 KB
/
event.test.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { strictEqual } from "node:assert";
import { createCloseEvent, createCustomEvent, createErrorEvent, createProgressEvent } from "./event.ts";
describe("event", () => {
if (typeof Event === "undefined")
return;
it("createErrorEvent", () => {
const event = createErrorEvent("error", {
message: "Something went wrong.",
filename: "",
lineno: 1,
colno: 13,
});
strictEqual(event.type, "error");
strictEqual(event.message, "Something went wrong.");
strictEqual(event.filename, "");
strictEqual(event.lineno, 1);
strictEqual(event.colno, 13);
});
it("createCloseEvent", () => {
const event = createCloseEvent("close", {
code: 1000,
reason: "Normal closure",
wasClean: true,
});
strictEqual(event.type, "close");
strictEqual(event.code, 1000);
strictEqual(event.reason, "Normal closure");
strictEqual(event.wasClean, true);
});
it("createProgressEvent", () => {
const event = createProgressEvent("progress", {
lengthComputable: true,
loaded: 50,
total: 100,
});
strictEqual(event.type, "progress");
strictEqual(event.lengthComputable, true);
strictEqual(event.loaded, 50);
strictEqual(event.total, 100);
});
it("createCustomEvent", () => {
const event = createCustomEvent("custom", {
detail: "Hello, world!",
});
strictEqual(event.type, "custom");
strictEqual(event.detail, "Hello, world!");
});
});