uptime-kuma/test/backend-test/test-status-page.js
Frank Elsinga 0f61d7ee1b
chore: enable formatting over the entire codebase in CI (#6655)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-01-09 02:10:36 +01:00

43 lines
1.8 KiB
JavaScript

const { describe, test } = require("node:test");
const assert = require("node:assert");
const StatusPage = require("../../server/model/status_page");
const {
STATUS_PAGE_ALL_UP,
STATUS_PAGE_ALL_DOWN,
STATUS_PAGE_PARTIAL_DOWN,
STATUS_PAGE_MAINTENANCE,
} = require("../../src/util");
describe("StatusPage", () => {
describe("getStatusDescription()", () => {
test("returns 'No Services' when status is -1", () => {
const description = StatusPage.getStatusDescription(-1);
assert.strictEqual(description, "No Services");
});
test("returns 'All Systems Operational' when all services are up", () => {
const description = StatusPage.getStatusDescription(STATUS_PAGE_ALL_UP);
assert.strictEqual(description, "All Systems Operational");
});
test("returns 'Partially Degraded Service' when some services are down", () => {
const description = StatusPage.getStatusDescription(STATUS_PAGE_PARTIAL_DOWN);
assert.strictEqual(description, "Partially Degraded Service");
});
test("returns 'Degraded Service' when all services are down", () => {
const description = StatusPage.getStatusDescription(STATUS_PAGE_ALL_DOWN);
assert.strictEqual(description, "Degraded Service");
});
test("returns 'Under maintenance' when status page is in maintenance", () => {
const description = StatusPage.getStatusDescription(STATUS_PAGE_MAINTENANCE);
assert.strictEqual(description, "Under maintenance");
});
test("returns '?' for unknown status values", () => {
const description = StatusPage.getStatusDescription(999);
assert.strictEqual(description, "?");
});
});
});