Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
import { describe, expect, test } from "vitest";
import { statusPageFrom } from "./sender";
describe("statusPageFrom", () => {
test("quotes the page title", () => {
expect(statusPageFrom("Acme")).toBe(
'"Acme" <[email protected]>',
);
});
test("keeps commas inside the quoted name", () => {
expect(statusPageFrom("Acme, Inc.")).toBe(
'"Acme, Inc." <[email protected]>',
);
});
test("strips characters that would break the header", () => {
expect(statusPageFrom('Acme "EU" <status>\r\nBcc: x\\y')).toBe(
'"Acme EU status Bcc: x y" <[email protected]>',
);
});
test("strips @ so the name can't pose as an address", () => {
expect(statusPageFrom("[email protected]")).toBe(
'"security paypal.com" <[email protected]>',
);
});
test("caps the length without splitting characters", () => {
const from = statusPageFrom(`${"a".repeat(59)}ππ`);
expect(from).toBe(
`"${"a".repeat(59)}π" <[email protected]>`,
);
});
test("falls back to openstatus when nothing is left", () => {
expect(statusPageFrom(' "<>" ')).toBe(
'"openstatus" <[email protected]>',
);
expect(statusPageFrom(null)).toBe(
'"openstatus" <[email protected]>',
);
});
});