Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.

Commit 90afe2b

Browse files
Batta32darrenj
authored andcommitted
[Botskills] Implement logger tests (#1915)
* Add logger tests * Remove unused var
1 parent e718581 commit 90afe2b

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* Copyright(c) Microsoft Corporation.All rights reserved.
3+
* Licensed under the MIT License.
4+
*/
5+
6+
const { ok } = require("assert");
7+
const { ConsoleLogger } = require("../lib/logger");
8+
const sandbox = require("sinon").createSandbox();
9+
const logger = new ConsoleLogger();
10+
const message = "Custom Message";
11+
const command = "Custom Command";
12+
13+
describe("The logger", function () {
14+
beforeEach(function () {
15+
this.stubError = sandbox.spy(console, 'error');
16+
this.stubMessage = sandbox.spy(console, 'log');
17+
});
18+
19+
afterEach(function() {
20+
this.stubError.restore();
21+
this.stubMessage.restore();
22+
});
23+
24+
describe("should print", function(){
25+
it("the custom error message", function() {
26+
logger.error(message);
27+
ok(this.stubError.called);
28+
ok(logger.isError);
29+
});
30+
31+
it("the custom informative message", function() {
32+
logger.message(message);
33+
ok(this.stubMessage.called);
34+
});
35+
36+
it("the custom success message", function() {
37+
logger.success(message);
38+
ok(this.stubMessage.called);
39+
});
40+
41+
it("the custom warning message", function() {
42+
logger.warning(message);
43+
ok(this.stubMessage.called);
44+
});
45+
46+
describe("the custom command message without verbose flag", function() {
47+
it("without verbose flag", function() {
48+
logger.isVerbose = undefined;
49+
logger.command(message, command);
50+
ok(this.stubMessage.called);
51+
});
52+
53+
it("with verbose flag", function() {
54+
logger.isVerbose = true;
55+
logger.command(message, command);
56+
ok(this.stubMessage.called);
57+
});
58+
});
59+
});
60+
});

0 commit comments

Comments
 (0)