UNPKG

3.09 kBJavaScriptView Raw
1const print = require("../src/messenger");
2const pkgInfo = require("../package.json");
3
4const {
5 critical,
6 error,
7 success,
8 warning,
9 warn,
10 important,
11 info,
12 notice,
13 note,
14 status,
15 debug,
16 log,
17 center,
18 line
19} = require("../src/messenger");
20
21describe(classLabel("Messenger Class"), () => {
22 let message;
23 beforeEach(() => {
24 message = "Messenger Test";
25 });
26 describe(commandLabel("Miscellaneous"), () => {
27 test("version returns `pkgInfo.version` property", done => {
28 expect(print.version()).toEqual(pkgInfo.version);
29 done();
30 });
31 test("console.log has been called", done => {
32 // https://stackoverflow.com/questions/44467657/jest-better-way-to-disable-console-inside-unit-tests
33 console.log = jest.fn();
34 console.log("hello world");
35 expect(console.log).toHaveBeenCalled();
36 done();
37 });
38 });
39 describe(commandLabel("Critical"), () => {
40 test("critical static", () => {
41 expect(typeof critical).toBe("function");
42 critical(message);
43 });
44 });
45 describe(commandLabel("Error"), () => {
46 test("error static", () => {
47 expect(typeof error).toBe("function");
48 error(message);
49 });
50 });
51 describe(commandLabel("Success"), () => {
52 test("success static", () => {
53 expect(typeof success).toBe("function");
54 success(message);
55 });
56 });
57 describe(commandLabel("Warning"), () => {
58 test("warning static", () => {
59 expect(typeof warning).toBe("function");
60 warning(message);
61 });
62 });
63 describe(commandLabel("Warn"), () => {
64 test("warn static", () => {
65 expect(typeof warn).toBe("function");
66 warn(message);
67 });
68 });
69 describe(commandLabel("Info"), () => {
70 test("info static", () => {
71 expect(typeof info).toBe("function");
72 info(message);
73 });
74 });
75 describe(commandLabel("Important"), () => {
76 test("important static", () => {
77 expect(typeof important).toBe("function");
78 important(message);
79 });
80 });
81 describe(commandLabel("Status"), () => {
82 test("status static", () => {
83 expect(typeof status).toBe("function");
84 status(message);
85 });
86 });
87 describe(commandLabel("Note"), () => {
88 test("note static", () => {
89 expect(typeof note).toBe("function");
90 note(message);
91 });
92 });
93 describe(commandLabel("Notice"), () => {
94 test("notice static", () => {
95 expect(typeof notice).toBe("function");
96 notice(message);
97 });
98 });
99 describe(commandLabel("Log"), () => {
100 test("log static", () => {
101 expect(typeof log).toBe("function");
102 log(message);
103 });
104 });
105 describe(commandLabel("Debug"), () => {
106 test("debug static", () => {
107 expect(typeof debug).toBe("function");
108 debug(message);
109 });
110 });
111 describe(commandLabel("Center"), () => {
112 test("center static", () => {
113 expect(typeof center).toBe("function");
114 center(message);
115 });
116 });
117 describe(commandLabel("Line"), () => {
118 test("line static", () => {
119 expect(typeof line).toBe("function");
120 line(message);
121 });
122 });
123});