@tkeron/tools 0.2.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/npm_deploy.yml +12 -8
- package/bun.lock +8 -8
- package/changelog.md +42 -0
- package/package.json +13 -4
- package/readme.md +83 -7
- package/src/createTestLogger.ts +31 -0
- package/src/getPaths.ts +90 -103
- package/src/index.ts +3 -0
- package/src/loggerObj.ts +13 -0
- package/src/silentLogger.ts +8 -0
- package/src/stack.ts +46 -63
- package/tests/createTestLogger.test.ts +392 -0
- package/tests/getPaths.test.ts +528 -0
- package/tests/loggerObj.test.ts +285 -0
- package/{src → tests}/random.test.ts +1 -1
- package/tests/silentLogger.test.ts +246 -0
- package/{src → tests}/stack.test.ts +2 -2
- package/src/getPaths.test.ts +0 -513
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { describe, it, expect, spyOn, beforeEach, afterEach } from "bun:test";
|
|
2
|
+
import { logger } from "../src/loggerObj.js";
|
|
3
|
+
import type { Logger } from "../src/loggerObj.js";
|
|
4
|
+
|
|
5
|
+
describe("Logger interface", () => {
|
|
6
|
+
it("should have all required methods", () => {
|
|
7
|
+
expect(logger).toHaveProperty("log");
|
|
8
|
+
expect(logger).toHaveProperty("error");
|
|
9
|
+
expect(logger).toHaveProperty("warn");
|
|
10
|
+
expect(logger).toHaveProperty("info");
|
|
11
|
+
expect(typeof logger.log).toBe("function");
|
|
12
|
+
expect(typeof logger.error).toBe("function");
|
|
13
|
+
expect(typeof logger.warn).toBe("function");
|
|
14
|
+
expect(typeof logger.info).toBe("function");
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe("logger.log", () => {
|
|
19
|
+
let logSpy: any;
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
logSpy = spyOn(console, "log");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
afterEach(() => {
|
|
26
|
+
logSpy.mockRestore();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("should call console.log with single string", () => {
|
|
30
|
+
logger.log("test message");
|
|
31
|
+
expect(logSpy).toHaveBeenCalledWith("test message");
|
|
32
|
+
expect(logSpy).toHaveBeenCalledTimes(1);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("should call console.log with multiple arguments", () => {
|
|
36
|
+
logger.log("test", "multiple", "args");
|
|
37
|
+
expect(logSpy).toHaveBeenCalledWith("test", "multiple", "args");
|
|
38
|
+
expect(logSpy).toHaveBeenCalledTimes(1);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("should call console.log with number", () => {
|
|
42
|
+
logger.log(42);
|
|
43
|
+
expect(logSpy).toHaveBeenCalledWith(42);
|
|
44
|
+
expect(logSpy).toHaveBeenCalledTimes(1);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("should call console.log with object", () => {
|
|
48
|
+
const obj = { key: "value" };
|
|
49
|
+
logger.log(obj);
|
|
50
|
+
expect(logSpy).toHaveBeenCalledWith(obj);
|
|
51
|
+
expect(logSpy).toHaveBeenCalledTimes(1);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("should call console.log with array", () => {
|
|
55
|
+
const arr = [1, 2, 3];
|
|
56
|
+
logger.log(arr);
|
|
57
|
+
expect(logSpy).toHaveBeenCalledWith(arr);
|
|
58
|
+
expect(logSpy).toHaveBeenCalledTimes(1);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("should call console.log with null", () => {
|
|
62
|
+
logger.log(null);
|
|
63
|
+
expect(logSpy).toHaveBeenCalledWith(null);
|
|
64
|
+
expect(logSpy).toHaveBeenCalledTimes(1);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("should call console.log with undefined", () => {
|
|
68
|
+
logger.log(undefined);
|
|
69
|
+
expect(logSpy).toHaveBeenCalledWith(undefined);
|
|
70
|
+
expect(logSpy).toHaveBeenCalledTimes(1);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("should call console.log with boolean", () => {
|
|
74
|
+
logger.log(true);
|
|
75
|
+
expect(logSpy).toHaveBeenCalledWith(true);
|
|
76
|
+
expect(logSpy).toHaveBeenCalledTimes(1);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("should call console.log with mixed types", () => {
|
|
80
|
+
logger.log("string", 42, { key: "value" }, [1, 2], null, undefined, true);
|
|
81
|
+
expect(logSpy).toHaveBeenCalledWith(
|
|
82
|
+
"string",
|
|
83
|
+
42,
|
|
84
|
+
{ key: "value" },
|
|
85
|
+
[1, 2],
|
|
86
|
+
null,
|
|
87
|
+
undefined,
|
|
88
|
+
true,
|
|
89
|
+
);
|
|
90
|
+
expect(logSpy).toHaveBeenCalledTimes(1);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("should call console.log with no arguments", () => {
|
|
94
|
+
logger.log();
|
|
95
|
+
expect(logSpy).toHaveBeenCalledWith();
|
|
96
|
+
expect(logSpy).toHaveBeenCalledTimes(1);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("should call console.log multiple times independently", () => {
|
|
100
|
+
logger.log("first");
|
|
101
|
+
logger.log("second");
|
|
102
|
+
logger.log("third");
|
|
103
|
+
expect(logSpy).toHaveBeenCalledTimes(3);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("should call console.log with empty string", () => {
|
|
107
|
+
logger.log("");
|
|
108
|
+
expect(logSpy).toHaveBeenCalledWith("");
|
|
109
|
+
expect(logSpy).toHaveBeenCalledTimes(1);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("should call console.log with zero", () => {
|
|
113
|
+
logger.log(0);
|
|
114
|
+
expect(logSpy).toHaveBeenCalledWith(0);
|
|
115
|
+
expect(logSpy).toHaveBeenCalledTimes(1);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("should call console.log with negative number", () => {
|
|
119
|
+
logger.log(-42);
|
|
120
|
+
expect(logSpy).toHaveBeenCalledWith(-42);
|
|
121
|
+
expect(logSpy).toHaveBeenCalledTimes(1);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("should call console.log with NaN", () => {
|
|
125
|
+
logger.log(NaN);
|
|
126
|
+
expect(logSpy).toHaveBeenCalledWith(NaN);
|
|
127
|
+
expect(logSpy).toHaveBeenCalledTimes(1);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("should call console.log with Infinity", () => {
|
|
131
|
+
logger.log(Infinity);
|
|
132
|
+
expect(logSpy).toHaveBeenCalledWith(Infinity);
|
|
133
|
+
expect(logSpy).toHaveBeenCalledTimes(1);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
describe("logger.error", () => {
|
|
138
|
+
let errorSpy: any;
|
|
139
|
+
|
|
140
|
+
beforeEach(() => {
|
|
141
|
+
errorSpy = spyOn(console, "error");
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
afterEach(() => {
|
|
145
|
+
errorSpy.mockRestore();
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it("should call console.error with single string", () => {
|
|
149
|
+
logger.error("error message");
|
|
150
|
+
expect(errorSpy).toHaveBeenCalledWith("error message");
|
|
151
|
+
expect(errorSpy).toHaveBeenCalledTimes(1);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it("should call console.error with multiple arguments", () => {
|
|
155
|
+
logger.error("error", "multiple", "args");
|
|
156
|
+
expect(errorSpy).toHaveBeenCalledWith("error", "multiple", "args");
|
|
157
|
+
expect(errorSpy).toHaveBeenCalledTimes(1);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it("should call console.error with Error object", () => {
|
|
161
|
+
const error = new Error("test error");
|
|
162
|
+
logger.error(error);
|
|
163
|
+
expect(errorSpy).toHaveBeenCalledWith(error);
|
|
164
|
+
expect(errorSpy).toHaveBeenCalledTimes(1);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it("should call console.error with null", () => {
|
|
168
|
+
logger.error(null);
|
|
169
|
+
expect(errorSpy).toHaveBeenCalledWith(null);
|
|
170
|
+
expect(errorSpy).toHaveBeenCalledTimes(1);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it("should call console.error with undefined", () => {
|
|
174
|
+
logger.error(undefined);
|
|
175
|
+
expect(errorSpy).toHaveBeenCalledWith(undefined);
|
|
176
|
+
expect(errorSpy).toHaveBeenCalledTimes(1);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it("should call console.error with no arguments", () => {
|
|
180
|
+
logger.error();
|
|
181
|
+
expect(errorSpy).toHaveBeenCalledWith();
|
|
182
|
+
expect(errorSpy).toHaveBeenCalledTimes(1);
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
describe("logger.warn", () => {
|
|
187
|
+
let warnSpy: any;
|
|
188
|
+
|
|
189
|
+
beforeEach(() => {
|
|
190
|
+
warnSpy = spyOn(console, "warn");
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
afterEach(() => {
|
|
194
|
+
warnSpy.mockRestore();
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it("should call console.warn with single string", () => {
|
|
198
|
+
logger.warn("warning message");
|
|
199
|
+
expect(warnSpy).toHaveBeenCalledWith("warning message");
|
|
200
|
+
expect(warnSpy).toHaveBeenCalledTimes(1);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it("should call console.warn with multiple arguments", () => {
|
|
204
|
+
logger.warn("warn", "multiple", "args");
|
|
205
|
+
expect(warnSpy).toHaveBeenCalledWith("warn", "multiple", "args");
|
|
206
|
+
expect(warnSpy).toHaveBeenCalledTimes(1);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it("should call console.warn with null", () => {
|
|
210
|
+
logger.warn(null);
|
|
211
|
+
expect(warnSpy).toHaveBeenCalledWith(null);
|
|
212
|
+
expect(warnSpy).toHaveBeenCalledTimes(1);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it("should call console.warn with undefined", () => {
|
|
216
|
+
logger.warn(undefined);
|
|
217
|
+
expect(warnSpy).toHaveBeenCalledWith(undefined);
|
|
218
|
+
expect(warnSpy).toHaveBeenCalledTimes(1);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it("should call console.warn with no arguments", () => {
|
|
222
|
+
logger.warn();
|
|
223
|
+
expect(warnSpy).toHaveBeenCalledWith();
|
|
224
|
+
expect(warnSpy).toHaveBeenCalledTimes(1);
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
describe("logger.info", () => {
|
|
229
|
+
let infoSpy: any;
|
|
230
|
+
|
|
231
|
+
beforeEach(() => {
|
|
232
|
+
infoSpy = spyOn(console, "info");
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
afterEach(() => {
|
|
236
|
+
infoSpy.mockRestore();
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it("should call console.info with single string", () => {
|
|
240
|
+
logger.info("info message");
|
|
241
|
+
expect(infoSpy).toHaveBeenCalledWith("info message");
|
|
242
|
+
expect(infoSpy).toHaveBeenCalledTimes(1);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it("should call console.info with multiple arguments", () => {
|
|
246
|
+
logger.info("info", "multiple", "args");
|
|
247
|
+
expect(infoSpy).toHaveBeenCalledWith("info", "multiple", "args");
|
|
248
|
+
expect(infoSpy).toHaveBeenCalledTimes(1);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it("should call console.info with null", () => {
|
|
252
|
+
logger.info(null);
|
|
253
|
+
expect(infoSpy).toHaveBeenCalledWith(null);
|
|
254
|
+
expect(infoSpy).toHaveBeenCalledTimes(1);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it("should call console.info with undefined", () => {
|
|
258
|
+
logger.info(undefined);
|
|
259
|
+
expect(infoSpy).toHaveBeenCalledWith(undefined);
|
|
260
|
+
expect(infoSpy).toHaveBeenCalledTimes(1);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
it("should call console.info with no arguments", () => {
|
|
264
|
+
logger.info();
|
|
265
|
+
expect(infoSpy).toHaveBeenCalledWith();
|
|
266
|
+
expect(infoSpy).toHaveBeenCalledTimes(1);
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
describe("Logger type compatibility", () => {
|
|
271
|
+
it("should be compatible with Logger interface", () => {
|
|
272
|
+
const testLogger: Logger = logger;
|
|
273
|
+
expect(testLogger).toBeDefined();
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it("should allow custom Logger implementation", () => {
|
|
277
|
+
const customLogger: Logger = {
|
|
278
|
+
log: () => {},
|
|
279
|
+
error: () => {},
|
|
280
|
+
warn: () => {},
|
|
281
|
+
info: () => {},
|
|
282
|
+
};
|
|
283
|
+
expect(customLogger).toBeDefined();
|
|
284
|
+
});
|
|
285
|
+
});
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { describe, it, expect, spyOn, beforeEach, afterEach } from "bun:test";
|
|
2
|
+
import { silentLogger } from "../src/silentLogger.js";
|
|
3
|
+
import type { Logger } from "../src/loggerObj.js";
|
|
4
|
+
|
|
5
|
+
describe("silentLogger interface", () => {
|
|
6
|
+
it("should have all required Logger methods", () => {
|
|
7
|
+
expect(silentLogger).toHaveProperty("log");
|
|
8
|
+
expect(silentLogger).toHaveProperty("error");
|
|
9
|
+
expect(silentLogger).toHaveProperty("warn");
|
|
10
|
+
expect(silentLogger).toHaveProperty("info");
|
|
11
|
+
expect(typeof silentLogger.log).toBe("function");
|
|
12
|
+
expect(typeof silentLogger.error).toBe("function");
|
|
13
|
+
expect(typeof silentLogger.warn).toBe("function");
|
|
14
|
+
expect(typeof silentLogger.info).toBe("function");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("should be compatible with Logger type", () => {
|
|
18
|
+
const testLogger: Logger = silentLogger;
|
|
19
|
+
expect(testLogger).toBeDefined();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe("silentLogger.log", () => {
|
|
24
|
+
let logSpy: any;
|
|
25
|
+
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
logSpy = spyOn(console, "log");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
afterEach(() => {
|
|
31
|
+
logSpy.mockRestore();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should not call console.log with single string", () => {
|
|
35
|
+
silentLogger.log("test message");
|
|
36
|
+
expect(logSpy).not.toHaveBeenCalled();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("should not call console.log with multiple arguments", () => {
|
|
40
|
+
silentLogger.log("test", "multiple", "args");
|
|
41
|
+
expect(logSpy).not.toHaveBeenCalled();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("should not call console.log with object", () => {
|
|
45
|
+
silentLogger.log({ key: "value" });
|
|
46
|
+
expect(logSpy).not.toHaveBeenCalled();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("should not call console.log with null", () => {
|
|
50
|
+
silentLogger.log(null);
|
|
51
|
+
expect(logSpy).not.toHaveBeenCalled();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("should not call console.log with undefined", () => {
|
|
55
|
+
silentLogger.log(undefined);
|
|
56
|
+
expect(logSpy).not.toHaveBeenCalled();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("should not call console.log with no arguments", () => {
|
|
60
|
+
silentLogger.log();
|
|
61
|
+
expect(logSpy).not.toHaveBeenCalled();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("should not call console.log when called multiple times", () => {
|
|
65
|
+
silentLogger.log("first");
|
|
66
|
+
silentLogger.log("second");
|
|
67
|
+
silentLogger.log("third");
|
|
68
|
+
expect(logSpy).not.toHaveBeenCalled();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("should not throw when called", () => {
|
|
72
|
+
expect(() => silentLogger.log("test")).not.toThrow();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("should return undefined", () => {
|
|
76
|
+
const result = silentLogger.log("test");
|
|
77
|
+
expect(result).toBeUndefined();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe("silentLogger.error", () => {
|
|
82
|
+
let errorSpy: any;
|
|
83
|
+
|
|
84
|
+
beforeEach(() => {
|
|
85
|
+
errorSpy = spyOn(console, "error");
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
afterEach(() => {
|
|
89
|
+
errorSpy.mockRestore();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("should not call console.error with single string", () => {
|
|
93
|
+
silentLogger.error("error message");
|
|
94
|
+
expect(errorSpy).not.toHaveBeenCalled();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("should not call console.error with multiple arguments", () => {
|
|
98
|
+
silentLogger.error("error", "multiple", "args");
|
|
99
|
+
expect(errorSpy).not.toHaveBeenCalled();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("should not call console.error with Error object", () => {
|
|
103
|
+
silentLogger.error(new Error("test error"));
|
|
104
|
+
expect(errorSpy).not.toHaveBeenCalled();
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("should not call console.error with null", () => {
|
|
108
|
+
silentLogger.error(null);
|
|
109
|
+
expect(errorSpy).not.toHaveBeenCalled();
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("should not call console.error with undefined", () => {
|
|
113
|
+
silentLogger.error(undefined);
|
|
114
|
+
expect(errorSpy).not.toHaveBeenCalled();
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it("should not call console.error with no arguments", () => {
|
|
118
|
+
silentLogger.error();
|
|
119
|
+
expect(errorSpy).not.toHaveBeenCalled();
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("should not throw when called", () => {
|
|
123
|
+
expect(() => silentLogger.error("test")).not.toThrow();
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("should return undefined", () => {
|
|
127
|
+
const result = silentLogger.error("test");
|
|
128
|
+
expect(result).toBeUndefined();
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
describe("silentLogger.warn", () => {
|
|
133
|
+
let warnSpy: any;
|
|
134
|
+
|
|
135
|
+
beforeEach(() => {
|
|
136
|
+
warnSpy = spyOn(console, "warn");
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
afterEach(() => {
|
|
140
|
+
warnSpy.mockRestore();
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it("should not call console.warn with single string", () => {
|
|
144
|
+
silentLogger.warn("warning message");
|
|
145
|
+
expect(warnSpy).not.toHaveBeenCalled();
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it("should not call console.warn with multiple arguments", () => {
|
|
149
|
+
silentLogger.warn("warn", "multiple", "args");
|
|
150
|
+
expect(warnSpy).not.toHaveBeenCalled();
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it("should not call console.warn with null", () => {
|
|
154
|
+
silentLogger.warn(null);
|
|
155
|
+
expect(warnSpy).not.toHaveBeenCalled();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("should not call console.warn with undefined", () => {
|
|
159
|
+
silentLogger.warn(undefined);
|
|
160
|
+
expect(warnSpy).not.toHaveBeenCalled();
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it("should not call console.warn with no arguments", () => {
|
|
164
|
+
silentLogger.warn();
|
|
165
|
+
expect(warnSpy).not.toHaveBeenCalled();
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it("should not throw when called", () => {
|
|
169
|
+
expect(() => silentLogger.warn("test")).not.toThrow();
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("should return undefined", () => {
|
|
173
|
+
const result = silentLogger.warn("test");
|
|
174
|
+
expect(result).toBeUndefined();
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
describe("silentLogger.info", () => {
|
|
179
|
+
let infoSpy: any;
|
|
180
|
+
|
|
181
|
+
beforeEach(() => {
|
|
182
|
+
infoSpy = spyOn(console, "info");
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
afterEach(() => {
|
|
186
|
+
infoSpy.mockRestore();
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it("should not call console.info with single string", () => {
|
|
190
|
+
silentLogger.info("info message");
|
|
191
|
+
expect(infoSpy).not.toHaveBeenCalled();
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it("should not call console.info with multiple arguments", () => {
|
|
195
|
+
silentLogger.info("info", "multiple", "args");
|
|
196
|
+
expect(infoSpy).not.toHaveBeenCalled();
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it("should not call console.info with null", () => {
|
|
200
|
+
silentLogger.info(null);
|
|
201
|
+
expect(infoSpy).not.toHaveBeenCalled();
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it("should not call console.info with undefined", () => {
|
|
205
|
+
silentLogger.info(undefined);
|
|
206
|
+
expect(infoSpy).not.toHaveBeenCalled();
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it("should not call console.info with no arguments", () => {
|
|
210
|
+
silentLogger.info();
|
|
211
|
+
expect(infoSpy).not.toHaveBeenCalled();
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it("should not throw when called", () => {
|
|
215
|
+
expect(() => silentLogger.info("test")).not.toThrow();
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it("should return undefined", () => {
|
|
219
|
+
const result = silentLogger.info("test");
|
|
220
|
+
expect(result).toBeUndefined();
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
describe("silentLogger behavior", () => {
|
|
225
|
+
it("should not produce any console output when all methods are called", () => {
|
|
226
|
+
const logSpy = spyOn(console, "log");
|
|
227
|
+
const errorSpy = spyOn(console, "error");
|
|
228
|
+
const warnSpy = spyOn(console, "warn");
|
|
229
|
+
const infoSpy = spyOn(console, "info");
|
|
230
|
+
|
|
231
|
+
silentLogger.log("test");
|
|
232
|
+
silentLogger.error("test");
|
|
233
|
+
silentLogger.warn("test");
|
|
234
|
+
silentLogger.info("test");
|
|
235
|
+
|
|
236
|
+
expect(logSpy).not.toHaveBeenCalled();
|
|
237
|
+
expect(errorSpy).not.toHaveBeenCalled();
|
|
238
|
+
expect(warnSpy).not.toHaveBeenCalled();
|
|
239
|
+
expect(infoSpy).not.toHaveBeenCalled();
|
|
240
|
+
|
|
241
|
+
logSpy.mockRestore();
|
|
242
|
+
errorSpy.mockRestore();
|
|
243
|
+
warnSpy.mockRestore();
|
|
244
|
+
infoSpy.mockRestore();
|
|
245
|
+
});
|
|
246
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect } from "bun:test";
|
|
2
|
-
import { getFIFO } from "
|
|
3
|
-
import { getLIFO } from "
|
|
2
|
+
import { getFIFO } from "../src/stack.js";
|
|
3
|
+
import { getLIFO } from "../src/stack.js";
|
|
4
4
|
|
|
5
5
|
describe("LIFO stack tests", () => {
|
|
6
6
|
it("should create an empty lifo stack", () => {
|