UNPKG

3.88 kBJavaScriptView Raw
1"use strict";
2// *****************************************************************************
3// Copyright (C) 2018 Ericsson and others.
4//
5// This program and the accompanying materials are made available under the
6// terms of the Eclipse Public License v. 2.0 which is available at
7// http://www.eclipse.org/legal/epl-2.0.
8//
9// This Source Code may also be made available under the following Secondary
10// Licenses when the conditions for such availability set forth in the Eclipse
11// Public License v. 2.0 are satisfied: GNU General Public License, version 2
12// with the GNU Classpath Exception which is available at
13// https://www.gnu.org/software/classpath/license.html.
14//
15// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16// *****************************************************************************
17var __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};
23var __metadata = (this && this.__metadata) || function (k, v) {
24 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25};
26Object.defineProperty(exports, "__esModule", { value: true });
27const inversify_1 = require("inversify");
28const console_logger_server_1 = require("./console-logger-server");
29const logger_protocol_1 = require("../common/logger-protocol");
30const logger_watcher_1 = require("../common/logger-watcher");
31const logger_cli_contribution_1 = require("./logger-cli-contribution");
32const chai_1 = require("chai");
33let server;
34let logLevelCliContribution;
35let 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);
49MockLogLevelCliContribution = __decorate([
50 (0, inversify_1.injectable)()
51], MockLogLevelCliContribution);
52beforeEach(() => {
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});
61describe('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//# sourceMappingURL=console-logger-server.spec.js.map
\No newline at end of file