1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
18 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
19 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
20 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
21 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
22 | };
|
23 | var __metadata = (this && this.__metadata) || function (k, v) {
|
24 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
25 | };
|
26 | Object.defineProperty(exports, "__esModule", { value: true });
|
27 | const inversify_1 = require("inversify");
|
28 | const console_logger_server_1 = require("./console-logger-server");
|
29 | const logger_protocol_1 = require("../common/logger-protocol");
|
30 | const logger_watcher_1 = require("../common/logger-watcher");
|
31 | const logger_cli_contribution_1 = require("./logger-cli-contribution");
|
32 | const chai_1 = require("chai");
|
33 | let server;
|
34 | let logLevelCliContribution;
|
35 | let MockLogLevelCliContribution = class MockLogLevelCliContribution extends logger_cli_contribution_1.LogLevelCliContribution {
|
36 | init() {
|
37 | this._logLevels['test-logger'] = logger_protocol_1.LogLevel.DEBUG;
|
38 | }
|
39 | changeLogLevel(newLevel) {
|
40 | this._logLevels['test-logger'] = newLevel;
|
41 | }
|
42 | };
|
43 | __decorate([
|
44 | (0, inversify_1.postConstruct)(),
|
45 | __metadata("design:type", Function),
|
46 | __metadata("design:paramtypes", []),
|
47 | __metadata("design:returntype", void 0)
|
48 | ], MockLogLevelCliContribution.prototype, "init", null);
|
49 | MockLogLevelCliContribution = __decorate([
|
50 | (0, inversify_1.injectable)()
|
51 | ], MockLogLevelCliContribution);
|
52 | beforeEach(() => {
|
53 | const container = new inversify_1.Container;
|
54 | container.bind(console_logger_server_1.ConsoleLoggerServer).toSelf().inSingletonScope();
|
55 | container.bind(logger_watcher_1.LoggerWatcher).toSelf().inSingletonScope();
|
56 | container.bind(MockLogLevelCliContribution).toSelf().inSingletonScope();
|
57 | container.bind(logger_cli_contribution_1.LogLevelCliContribution).toService(MockLogLevelCliContribution);
|
58 | logLevelCliContribution = container.get(MockLogLevelCliContribution);
|
59 | server = container.get(console_logger_server_1.ConsoleLoggerServer);
|
60 | });
|
61 | describe('ConsoleLoggerServer', function () {
|
62 | it('should respect log level config', async function () {
|
63 | (0, chai_1.expect)(await server.getLogLevel('test-logger')).eq(logger_protocol_1.LogLevel.DEBUG);
|
64 | await server.child('test-logger');
|
65 | (0, chai_1.expect)(await server.getLogLevel('test-logger')).eq(logger_protocol_1.LogLevel.DEBUG);
|
66 | logLevelCliContribution.changeLogLevel(logger_protocol_1.LogLevel.WARN);
|
67 | (0, chai_1.expect)(await server.getLogLevel('test-logger')).eq(logger_protocol_1.LogLevel.WARN);
|
68 | });
|
69 | });
|
70 |
|
\ | No newline at end of file |