mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
Integrated into release/v3.8.8. 9 legit test alignments + 34 new test files kept; restored 5 masked assertions (sk_ key redaction, circular/SSN redaction, T24 wait-log, THEORY-004 SSE, relay handoff) to strict/meaningful checks. Thanks @oyi77!
63 lines
2.1 KiB
TypeScript
63 lines
2.1 KiB
TypeScript
import { describe, it } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
const mod = await import("../../open-sse/services/quotaMonitor.ts");
|
|
|
|
describe("quotaMonitor", () => {
|
|
describe("isQuotaMonitorEnabled", () => {
|
|
it("returns true when providerSpecificData.quotaMonitorEnabled is true", () => {
|
|
assert.equal(mod.isQuotaMonitorEnabled({ providerSpecificData: { quotaMonitorEnabled: true } }), true);
|
|
});
|
|
|
|
it("returns false when providerSpecificData is missing", () => {
|
|
assert.equal(mod.isQuotaMonitorEnabled({}), false);
|
|
});
|
|
|
|
it("returns false when quotaMonitorEnabled is false", () => {
|
|
assert.equal(mod.isQuotaMonitorEnabled({ providerSpecificData: { quotaMonitorEnabled: false } }), false);
|
|
});
|
|
|
|
it("returns false when providerSpecificData is null", () => {
|
|
assert.equal(mod.isQuotaMonitorEnabled({ providerSpecificData: null }), false);
|
|
});
|
|
});
|
|
|
|
describe("getActiveMonitorCount", () => {
|
|
it("returns a number", () => {
|
|
assert.equal(typeof mod.getActiveMonitorCount(), "number");
|
|
});
|
|
});
|
|
|
|
describe("getQuotaMonitorSnapshot", () => {
|
|
it("returns null for unknown session", () => {
|
|
assert.equal(mod.getQuotaMonitorSnapshot("nonexistent-" + Date.now()), null);
|
|
});
|
|
});
|
|
|
|
describe("getQuotaMonitorSnapshots", () => {
|
|
it("returns an array", () => {
|
|
const result = mod.getQuotaMonitorSnapshots();
|
|
assert.ok(Array.isArray(result));
|
|
});
|
|
});
|
|
|
|
describe("getQuotaMonitorSummary", () => {
|
|
it("returns expected shape", () => {
|
|
const summary = mod.getQuotaMonitorSummary();
|
|
assert.equal(typeof summary.active, "number");
|
|
assert.equal(typeof summary.alerting, "number");
|
|
assert.equal(typeof summary.exhausted, "number");
|
|
assert.equal(typeof summary.errors, "number");
|
|
assert.ok(typeof summary.statusCounts === "object");
|
|
assert.ok(typeof summary.byProvider === "object");
|
|
});
|
|
});
|
|
|
|
describe("clearQuotaMonitors", () => {
|
|
it("clears without throwing", () => {
|
|
mod.clearQuotaMonitors();
|
|
assert.equal(mod.getActiveMonitorCount(), 0);
|
|
});
|
|
});
|
|
});
|