mirror of
https://github.com/bitwarden/browser.git
synced 2024-06-26 10:35:48 +02:00
* Rename service-factory folder
* Move cryptographic service factories
* Move crypto models
* Move crypto services
* Move domain base class
* Platform code owners
* Move desktop log services
* Move log files
* Establish component library ownership
* Move background listeners
* Move background background
* Move localization to Platform
* Move browser alarms to Platform
* Move browser state to Platform
* Move CLI state to Platform
* Move Desktop native concerns to Platform
* Move flag and misc to Platform
* Lint fixes
* Move electron state to platform
* Move web state to Platform
* Move lib state to Platform
* Fix broken tests
* Rename interface to idiomatic TS
* `npm run prettier` 🤖
* Resolve review feedback
* Set platform as owners of web core and shared
* Expand moved services
* Fix test types
---------
Co-authored-by: Hinton <hinton@users.noreply.github.com>
59 lines
1.6 KiB
TypeScript
59 lines
1.6 KiB
TypeScript
import { interceptConsole, restoreConsole } from "../../../spec";
|
|
|
|
import { ConsoleLogService } from "./console-log.service";
|
|
|
|
let caughtMessage: any;
|
|
|
|
describe("ConsoleLogService", () => {
|
|
let logService: ConsoleLogService;
|
|
beforeEach(() => {
|
|
caughtMessage = {};
|
|
interceptConsole(caughtMessage);
|
|
logService = new ConsoleLogService(true);
|
|
});
|
|
|
|
afterAll(() => {
|
|
restoreConsole();
|
|
});
|
|
|
|
it("filters messages below the set threshold", () => {
|
|
logService = new ConsoleLogService(true, () => true);
|
|
logService.debug("debug");
|
|
logService.info("info");
|
|
logService.warning("warning");
|
|
logService.error("error");
|
|
|
|
expect(caughtMessage).toEqual({});
|
|
});
|
|
it("only writes debug messages in dev mode", () => {
|
|
logService = new ConsoleLogService(false);
|
|
|
|
logService.debug("debug message");
|
|
expect(caughtMessage.log).toBeUndefined();
|
|
});
|
|
|
|
it("writes debug/info messages to console.log", () => {
|
|
logService.debug("this is a debug message");
|
|
expect(caughtMessage).toMatchObject({
|
|
log: { "0": "this is a debug message" },
|
|
});
|
|
|
|
logService.info("this is an info message");
|
|
expect(caughtMessage).toMatchObject({
|
|
log: { "0": "this is an info message" },
|
|
});
|
|
});
|
|
it("writes warning messages to console.warn", () => {
|
|
logService.warning("this is a warning message");
|
|
expect(caughtMessage).toMatchObject({
|
|
warn: { 0: "this is a warning message" },
|
|
});
|
|
});
|
|
it("writes error messages to console.error", () => {
|
|
logService.error("this is an error message");
|
|
expect(caughtMessage).toMatchObject({
|
|
error: { 0: "this is an error message" },
|
|
});
|
|
});
|
|
});
|