deno.land / std@0.166.0 / node / perf_hooks_test.ts

perf_hooks_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
58
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.import * as perfHooks from "./perf_hooks.ts";import { performance } from "./perf_hooks.ts";import { assertEquals } from "../testing/asserts.ts";import { assertSpyCall, assertSpyCalls, spy } from "../testing/mock.ts";
Deno.test({ name: "[perf_hooks] performance", fn() { assertEquals(perfHooks.performance.measure, performance.measure); assertEquals(perfHooks.performance.clearMarks, performance.clearMarks); assertEquals(perfHooks.performance.mark, performance.mark); assertEquals(perfHooks.performance.now, performance.now); assertEquals(perfHooks.performance.toJSON, performance.toJSON); perfHooks.performance.measure("test"); perfHooks.performance.mark("test"); perfHooks.performance.clearMarks("test"); perfHooks.performance.now(); perfHooks.performance.toJSON(); },});
Deno.test({ name: "[perf_hooks] performance destructured", fn() { performance.measure("test"); performance.mark("test"); performance.clearMarks("test"); performance.now(); performance.toJSON(); },});
Deno.test({ name: "[perf_hooks] PerformanceEntry", fn() { assertEquals<unknown>(perfHooks.PerformanceEntry, PerformanceEntry); },});
Deno.test({ name: "[perf_hooks] EventTarget methods", fn() { const handler = spy(); performance.addEventListener("event", handler); assertSpyCalls(handler, 0); const e = new Event("event"); performance.dispatchEvent(e); // handler is called once assertSpyCalls(handler, 1); assertSpyCall(handler, 0, { args: [e] }); performance.removeEventListener("event", handler); performance.dispatchEvent(e); // handler is not called anymore assertSpyCalls(handler, 1); },});
std
Deno standard library
GitHub Repositorydenoland/deno_std
GitHub Stars
2447

Version Info

Tagged at
2 months ago