forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.spec.js
More file actions
42 lines (32 loc) · 966 Bytes
/
log.spec.js
File metadata and controls
42 lines (32 loc) · 966 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
36
37
38
39
40
41
42
import { log } from "../log.js";
let logArgFirst, logArgSecond, logArgArray, logPrefix;
describe("log()", () => {
beforeEach(() => {
logArgFirst = "my info";
logArgSecond = "my other info";
logArgArray = [logArgFirst, logArgSecond];
logPrefix = "[log]";
global.console = { log: jest.fn() };
});
describe("when isDevelopment", () => {
it("prints all arguments, prefixed with a log label", () => {
log(logArgArray);
expect(global.console.log).toHaveBeenCalledWith(logPrefix, logArgArray);
});
});
describe("when not isDevelopment", () => {
beforeEach(() => {
process.env.NODE_ENV = "production";
});
afterEach(() => {
delete process.env.NODE_ENV;
});
it("returns undefined", () => {
expect(log(logArgArray)).toEqual(undefined);
});
it("produces no logs", () => {
log(logArgArray);
expect(global.console.log).not.toHaveBeenCalled();
});
});
});