Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
2.1 kB ยท 69 lines
TypeScript
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970import { expect } from "@std/expect";import { describe, test } from "@std/testing/bdd";
import { detectMarkdown } from "./detect-markdown";
describe("detectMarkdown", () => { test(".md suffix stripped, source suffix", () => { expect( detectMarkdown({ pathname: "/monitors/123.md", accept: null }), ).toEqual({ wantsMarkdown: true, source: "suffix", pathname: "/monitors/123", }); });
test("root /.md โ /", () => { expect(detectMarkdown({ pathname: "/.md", accept: null })).toEqual({ wantsMarkdown: true, source: "suffix", pathname: "/", }); });
test("Accept: text/markdown โ source header, pathname untouched", () => { expect( detectMarkdown({ pathname: "/monitors", accept: "text/markdown" }), ).toEqual({ wantsMarkdown: true, source: "header", pathname: "/monitors" }); });
test("case-insensitive + multi-type Accept", () => { expect( detectMarkdown({ pathname: "/", accept: "text/html, text/Markdown;q=0.9", }), ).toEqual({ wantsMarkdown: true, source: "header", pathname: "/" }); });
test("plain HTML accept โ not markdown", () => { expect( detectMarkdown({ pathname: "/monitors", accept: "text/html" }), ).toEqual({ wantsMarkdown: false, source: null, pathname: "/monitors" }); });
test("no accept header โ not markdown", () => { expect(detectMarkdown({ pathname: "/events", accept: null })).toEqual({ wantsMarkdown: false, source: null, pathname: "/events", }); });
test(".md that also matches Accept resolves to suffix", () => { expect( detectMarkdown({ pathname: "/monitors/1.md", accept: "text/markdown" }), ).toEqual({ wantsMarkdown: true, source: "suffix", pathname: "/monitors/1", }); });
test("partial token (text/markdownish) does not match", () => { expect( detectMarkdown({ pathname: "/", accept: "text/markdownish" }), ).toEqual({ wantsMarkdown: false, source: null, pathname: "/" }); });});