Files
web/packages/common/logger/createLogger/shouldLog.test.ts
Joakim Jäderberg 108bb2b319 Merged in chore/create-logger-tests (pull request #2996)
Tests for common/logger

* chore: add tests for createLogger

* chore: add tests for createLogger


Approved-by: Linus Flood
2025-10-24 13:28:56 +00:00

23 lines
827 B
TypeScript

import { describe, expect, it } from "vitest"
import { shouldLog } from "./shouldLog"
describe("shouldLog", () => {
it("returns true when log level is higher or equal to minimum", () => {
expect(shouldLog("info", "debug")).toBe(true)
expect(shouldLog("info", "info")).toBe(true)
expect(shouldLog("warn", "info")).toBe(true)
expect(shouldLog("warn", "warn")).toBe(true)
expect(shouldLog("error", "error")).toBe(true)
})
it("returns false when log level is lower than minimum", () => {
expect(shouldLog("debug", "info")).toBe(false)
expect(shouldLog("debug", "warn")).toBe(false)
expect(shouldLog("debug", "error")).toBe(false)
expect(shouldLog("info", "warn")).toBe(false)
expect(shouldLog("info", "error")).toBe(false)
expect(shouldLog("warn", "error")).toBe(false)
})
})