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
This commit is contained in:
Joakim Jäderberg
2025-10-24 13:28:56 +00:00
parent 3b3e7308cc
commit 108bb2b319
6 changed files with 53 additions and 23 deletions

View File

@@ -0,0 +1,22 @@
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)
})
})