forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDevToolsUtils.spec.js
More file actions
35 lines (27 loc) · 896 Bytes
/
DevToolsUtils.spec.js
File metadata and controls
35 lines (27 loc) · 896 Bytes
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
import { reportException, executeSoon } from "../DevToolsUtils.js";
describe("DevToolsUtils", () => {
describe("reportException", () => {
beforeEach(() => {
global.console = { error: jest.fn() };
});
it("calls console.error", () => {
reportException("caller", "you broke it");
expect(console.error).toBeCalled();
});
it("returns a description of caller and exception text", () => {
const who = {},
exception = "this is an error",
msgTxt = " threw an exception: ";
reportException(who, exception);
expect(console.error).toBeCalledWith(`${who}${msgTxt}`, exception);
});
});
describe("executeSoon", () => {
it("calls setTimeout with 0 ms", () => {
global.setTimeout = jest.fn();
const fnc = () => {};
executeSoon(fnc);
expect(setTimeout).toBeCalledWith(fnc, 0);
});
});
});