Tests / @ogygia/router

@ogygia/router

Version 0.14.0 latest
commit 620ddcca
137 test runs (137 tests, each run in Node, the browsers or both)
1.02× lines of test for each line of source (2,135 to 2,091) Only real test code counts: test files and their helpers, not fixtures, sample apps or benches. Blank lines are left out on both sides.
Exactly what is counted non-blank lines of test code across the repo (*.test.ts, *.test-d.ts, *.spec.ts, and the .ts helpers in test/ and e2e/ folders; no fixtures, fixture apps, stubs or benches), over non-blank lines of packages/*/src (no .d.ts or generated files)
95.2% of source lines run by the tests
  • 128Unit
  • 0Browser
  • 9End to end
  • 0Type tests
  • 0Lint rules
  • 0Failing

Coverage

  • 95.2%Lines
  • 82.2%Branches
  • 91.2%Functions
  • 92.6%Statements

Every test

137 tests

TestKindNodeChromiumFirefoxWebKit
packages/router/e2e/island-pkg.spec.ts
browser: package-internal island, deferred island, shipped route, .ts-table page all hydrateEnd to endnot runpasspasspass
SSR: all three surfaces render server HTMLEnd to endnot runpasspasspass
packages/router/e2e/router-seed.spec.ts
a router page whose islands read nothing ships no seedEnd to endnot runpasspasspass
an island that reads page.data gets it, shaped to the key it readsEnd to endnot runpasspasspass
packages/router/e2e/stream-page.spec.ts
browser: payload swapped in, template consumed, LATE island interactive + SPA-swap twinEnd to endnot runpasspasspass
late regions: a late region holding another promise region streams bothEnd to endnot runpasspasspass
late regions: a load promise-of-region resolves down the SAME responseEnd to endnot runpasspasspass
timing: the first chunk does NOT wait for the slow yieldEnd to endnot runpasspasspass
wire: skeleton before payload, payload inside an inert templateEnd to endnot runpasspasspass
packages/router/test/property-fill-match.test.ts
fill never builds a URL of another origin > an empty param that fills a first segment is refused (#1142)#1142Unitpassnot runnot runnot run
fill never builds a URL of another origin > whatever the params, the filled path stays on the origin it is read against, or is refusedUnitpassnot runnot runnot run
fill, read back through the URL parser > gives back the params as filled, or refuses themUnitpassnot runnot runnot run
fill, read back through the URL parser > refuses a param that would fill a whole segment with a dot segmentUnitpassnot runnot runnot run
packages/router/test/route-config-router.test.ts
route config × programmatic router > a `base` is stripped before matching; a path outside it is not this table’sUnitpassnot runnot runnot run
route config × programmatic router > a claimed-but-unset path shadows the file world; an unclaimed one falls through to itUnitpassnot runnot runnot run
route config × programmatic router > a page that sets nothing and an unmatched path both answer undefined (the default applies)Unitpassnot runnot runnot run
route config × programmatic router > dynamic patterns match like dispatchUnitpassnot runnot runnot run
route config × programmatic router > endpoints are not pages: claimed, nothing set, whatever the table saysUnitpassnot runnot runnot run
route config × programmatic router > nested layouts: the innermost wins over an outer oneUnitpassnot runnot runnot run
route config × programmatic router > page > layout > table — the deepest level winsUnitpassnot runnot runnot run
route config × programmatic router > re-registering the same table REPLACES its matcher (dev re-evaluation), never shadows itUnitpassnot runnot runnot run
route config × programmatic router > the merge is per key: a deeper config without the key keeps the outer valueUnitpassnot runnot runnot run
route config × programmatic router > two mounted tables: the one that claims the path answersUnitpassnot runnot runnot run
packages/router/test/router-allow-visitor-late.test.ts
a page’s verbs > a verb a page does not take is 405 with the same listUnitpassnot runnot runnot run
a page’s verbs > an empty actions table takes no POSTUnitpassnot runnot runnot run
a page’s verbs > OPTIONS on a page answers 204 with the verbs it takesUnitpassnot runnot runnot run
c.visitor > an anonymous answer is remembered too: the resolver runs onceUnitpassnot runnot runnot run
c.visitor > is worked out once per request, however often it is readUnitpassnot runnot runnot run
c.visitor > signed claims a shell attached win, and the resolver never runsUnitpassnot runnot runnot run
late regions > a rejected one streams its error card once, and the rest still comeUnitpassnot runnot runnot run
late regions > stream each once, in the order they finish, and then endUnitpassnot runnot runnot run
packages/router/test/router-api-browser-safe.test.ts
@ogygia/router/api > loads nothing but the path grammar, so an island can import it in the browserUnitpassnot runnot runnot run
packages/router/test/router-api-client.test.ts
api() — the typed endpoint client > a 200 whose JSON body does not parse rejects, it does not resolve undefinedUnitpassnot runnot runnot run
api() — the typed endpoint client > a null return answers 204 → resolves undefinedUnitpassnot runnot runnot run
api() — the typed endpoint client > a schema 400 throws ApiError carrying the issues bodyUnitpassnot runnot runnot run
api() — the typed endpoint client > an unmatched path throws ApiError 404Unitpassnot runnot runnot run
api() — the typed endpoint client > fills the pattern, carries the query, parses the typed payloadUnitpassnot runnot runnot run
api() — the typed endpoint client > POSTs the schema-typed body; the payload comes back typedUnitpassnot runnot runnot run
packages/router/test/router-define.test.ts
layout() > prepends itself to each page chain, outermost first, and passes endpoints through as they areUnitpassnot runnot runnot run
load() inside one request > a failed load is the request’s failure: the next call in it gets the same, without a runUnitpassnot runnot runnot run
load() inside one request > refuses a load asked for after its request ended, with the reason the request endedUnitpassnot runnot runnot run
page() actions > keeps an action() wrapper as it is and wraps a bare functionUnitpassnot runnot runnot run
packages/router/test/router-dispatch.test.ts
dispatch — base, slash, miss > 308-canonicalizes a trailing slash under slash:neverUnitpassnot runnot runnot run
dispatch — base, slash, miss > runs miss for an unmatched path under baseUnitpassnot runnot runnot run
dispatch — base, slash, miss > strips base, returns null for out-of-baseUnitpassnot runnot runnot run
dispatch — c.setHeaders reaches router-built responses > applies collected headers to the built responseUnitpassnot runnot runnot run
dispatch — c.setHeaders reaches router-built responses > never clobbers headers the handler set explicitlyUnitpassnot runnot runnot run
dispatch — endpoints, params, verbs > dispatches verbs, 405s the rest with allow, answers OPTIONSUnitpassnot runnot runnot run
dispatch — endpoints, params, verbs > falls through (null) on no match when unbasedUnitpassnot runnot runnot run
dispatch — endpoints, params, verbs > routes GET endpoints with params ([slug], [...rest])Unitpassnot runnot runnot run
dispatch — the trailing-slash redirect stays on the site > slash:always on "//other.example" redirects to a path on this hostUnitpassnot runnot runnot run
dispatch — the trailing-slash redirect stays on the site > slash:always on "/\\other.example" redirects to a path on this hostUnitpassnot runnot runnot run
dispatch — the trailing-slash redirect stays on the site > slash:never on "///other.example/x/" redirects to a path on this hostUnitpassnot runnot runnot run
dispatch — the trailing-slash redirect stays on the site > slash:never on "//other.example/" redirects to a path on this hostUnitpassnot runnot runnot run
dispatch — thrown redirect / error > error() from an endpoint → JSON errorUnitpassnot runnot runnot run
dispatch — thrown redirect / error > redirect() → a redirect responseUnitpassnot runnot runnot run
entries — prerender param sets for dynamic patterns > fills declared entries into the crawl list; undeclared dynamics are skippedUnitpassnot runnot runnot run
href — rename-safe links off the table keys > fills params + prefixes baseUnitpassnot runnot runnot run
layout names — one name, one layout, across the table > the same layout reused under its one name is fineUnitpassnot runnot runnot run
layout names — one name, one layout, across the table > two different layouts with the same name throw when the table is builtUnitpassnot runnot runnot run
loads — memoization + parent-sharing (no waterfall, no waste) > a shared load runs ONCE per request even when two loads await itUnitpassnot runnot runnot run
loads — memoization + parent-sharing (no waterfall, no waste) > memo is per-request (a second request re-runs)Unitpassnot runnot runnot run
miss — HTML boundary for page requests > unmatched NON-HTML request keeps the JSON 404 (fetch/API callers)Unitpassnot runnot runnot run
miss — HTML boundary for page requests > unmatched page GET under a base renders the root error page as HTML 404Unitpassnot runnot runnot run
pages — a thrown error finds its boundary > a flaky load that would pass a second time still names its own layer as the failed oneUnitpassnot runnot runnot run
pages — a thrown error finds its boundary > a layout load that throws synchronously is found as the failed layer tooUnitpassnot runnot runnot run
pages — a thrown error finds its boundary > a layout load’s error skips that layout’s own error page: the one above renders, without the failed layoutUnitpassnot runnot runnot run
pages — a thrown error finds its boundary > a page load’s error renders the innermost error page inside every layout, with their dataUnitpassnot runnot runnot run
pages — a thrown error finds its boundary > a POST to a named action the page does not have answers 404 and runs no action (the default included)Unitpassnot runnot runnot run
pages — a thrown error finds its boundary > an action’s error renders the innermost error page, every layout’s load having runUnitpassnot runnot runnot run
pages — a thrown error finds its boundary > an error page does not run the load that failed againUnitpassnot runnot runnot run
pages — a thrown error finds its boundary > with no error page anywhere, a page’s error answers JSONUnitpassnot runnot runnot run
pages — the branch’s loads > a page load that returns a Response is the answer: nothing rendersUnitpassnot runnot runnot run
pages — the branch’s loads > the layouts’ and the page’s loads all run before any of them ends (no waterfall)Unitpassnot runnot runnot run
pages — the branch’s loads > the loads’ data merges in branch order: the page’s wins over its layout’sUnitpassnot runnot runnot run
the table-wide load — a guard before every route > a Response it returns is the answer: the route never runsUnitpassnot runnot runnot run
the table-wide load — a guard before every route > its thrown redirect gates an endpoint tooUnitpassnot runnot runnot run
packages/router/test/router-layout-chain.test.ts
LayoutChain > hands a deferred page's fallback to it as its ogygiaFallback snippet, with the dataUnitpassnot runnot runnot run
LayoutChain > nests the layouts outermost first around the page, each reading the dataUnitpassnot runnot runnot run
packages/router/test/router-match.test.ts
router pattern matching > an [[optional]] that is not last counts for nothing, as in Kit: /[[lang]]/docs ranks as /docs (#1139)#1139Unitpassnot runnot runnot run
router pattern matching > distinguishes dot-suffixed and nested variants (the profiler /report cases)Unitpassnot runnot runnot run
router pattern matching > fill() drops the segment of an empty optional or rest param, as Kit doesUnitpassnot runnot runnot run
router pattern matching > fill() keeps the slashes of a rest value and encodes each of its segments, as Kit doesUnitpassnot runnot runnot run
router pattern matching > fill() puts URL-encoded params into every token kind, and nothing for a missing oneUnitpassnot runnot runnot run
router pattern matching > handles [...rest] (may be empty) and [[optional]]Unitpassnot runnot runnot run
router pattern matching > hands back a param with a malformed %xx as it was, instead of throwingUnitpassnot runnot runnot run
router pattern matching > is trailing-slash-insensitive and decodes paramsUnitpassnot runnot runnot run
router pattern matching > matches root, static, and paramsUnitpassnot runnot runnot run
router pattern matching > orders overlapping routes static > param > restUnitpassnot runnot runnot run
router pattern matching > REGRESSION: an empty-matching [...rest] must not shadow shorter routesUnitpassnot runnot runnot run
router pattern matching > rejects a segment with a stray bracket left after its valid [param] groupsUnitpassnot runnot runnot run
router pattern matching > rejects malformed patterns loudlyUnitpassnot runnot runnot run
router pattern matching takes time in line with the path > a param may hold the first character of the literal after it (#833)#833Unitpassnot runnot runnot run
router pattern matching takes time in line with the path > a path longer than any route can mean matches nothingUnitpassnot runnot runnot run
router pattern matching takes time in line with the path > a segment with several params answers a long path that almost matches at onceUnitpassnot runnot runnot run
router pattern matching takes time in line with the path > every short path splits as SvelteKit lazy params would (#833)#833Unitpassnot runnot runnot run
router pattern matching takes time in line with the path > several params in a segment split at the first separator, the last param takes the restUnitpassnot runnot runnot run
router pattern matching takes time in line with the path > two params with nothing between them answer a long near miss at once (#833)#833Unitpassnot runnot runnot run
packages/router/test/router-plugin.test.ts
router() marks every module importing @ogygia/router as a page moduleUnitpassnot runnot runnot run
packages/router/test/router-response-headers.test.ts
c.json() and c.text() keep the headers they are given (#1759) > a Headers object reaches the response, with the default content type#1759Unitpassnot runnot runnot run
c.json() and c.text() keep the headers they are given (#1759) > header pairs reach the response by name, not by index#1759Unitpassnot runnot runnot run
c.json() and c.text() keep the headers they are given (#1759) > json keeps its no-store default next to the given headers#1759Unitpassnot runnot runnot run
c.json() and c.text() keep the headers they are given (#1759) > the caller's content type replaces the default, whatever its case#1759Unitpassnot runnot runnot run
packages/router/test/router-route-order.test.ts
overlapping patterns resolve as Kit resolves them (#1139) > /[p] and /[[o]]/[p] at /c is /[p]#1139Unitpassnot runnot runnot run
overlapping patterns resolve as Kit resolves them (#1139) > /[p] and /[q] at /b is /[q]#1139Unitpassnot runnot runnot run
overlapping patterns resolve as Kit resolves them (#1139) > /[p].json and /[p]/[[o]] at /1.json is /[p].json#1139Unitpassnot runnot runnot run
overlapping patterns resolve as Kit resolves them (#1139) > /[p]/[...r] and /[[o]]/[[oz]] at /b is /[p]/[...r]#1139Unitpassnot runnot runnot run
overlapping patterns resolve as Kit resolves them (#1139) > /a and /[[lang]]/a at /a is /a#1139Unitpassnot runnot runnot run
overlapping patterns resolve as Kit resolves them (#1139) > /a/[...r] and /[p]/[q] at /a/b is /a/[...r]#1139Unitpassnot runnot runnot run
overlapping patterns resolve as Kit resolves them (#1139) > /b and /b/[[o]] at /b is /b#1139Unitpassnot runnot runnot run
overlapping patterns resolve as Kit resolves them (#1139) > /b/[...r] and /[[o]]/b/[...r] at /b is /b/[...r]#1139Unitpassnot runnot runnot run
the order a table is written in never changes a pick > two patterns that both match a path: the same winner either way roundUnitpassnot runnot runnot run
packages/router/test/router-schema.test.ts
endpoint body schema (POST/PUT/PATCH → c.input) > 400s a bad body with the issuesUnitpassnot runnot runnot run
endpoint body schema (POST/PUT/PATCH → c.input) > 400s a non-JSON bodyUnitpassnot runnot runnot run
endpoint body schema (POST/PUT/PATCH → c.input) > GET has no body schema — path on c.params, query on c.search (three clean surfaces)Unitpassnot runnot runnot run
endpoint body schema (POST/PUT/PATCH → c.input) > validates the JSON body and types c.inputUnitpassnot runnot runnot run
page-level search schema (typed search params → c.search, bad → 400) > 400s bad input with the issues, before any load runsUnitpassnot runnot runnot run
page-level search schema (typed search params → c.search, bad → 400) > applies the schema default when the param is absent (lenient)Unitpassnot runnot runnot run
page-level search schema (typed search params → c.search, bad → 400) > coerces good input into the typed c.search (string → number)Unitpassnot runnot runnot run
packages/router/test/router-stream-cancel.test.ts
a source whose cleanup fails as the visitor leaves > a page generator: request_cleanup_failed, with the errorUnitpassnot runnot runnot run
a source whose cleanup fails as the visitor leaves > a source a merged stream holds: request_cleanup_failed, with the errorUnitpassnot runnot runnot run
a streamed page the visitor left (#284) > cancelling a merged, drained stream ends every source it holds#284Unitpassnot runnot runnot run
a streamed page the visitor left (#284) > cancelling the body ends the page generator and renders nothing more#284Unitpassnot runnot runnot run
packages/router/test/router-stream-head.test.ts
the late boot in a streamed page > lands before a head end tag written with a spaceUnitpassnot runnot runnot run
the late boot in a streamed page > lands in the head, not in a comment before it that names the end tagUnitpassnot runnot runnot run
packages/router/test/router-stream.test.ts
a streamed response > adds no-transform to a cache-control the page set, keeping what it saidUnitpassnot runnot runnot run
a streamed response > drops a content-length the page response carried, so the stream is not cut shortUnitpassnot runnot runnot run
a streamed response > ends the page generator when the request it belongs to endsUnitpassnot runnot runnot run
a streamed response > leaves a cache-control that already says no-transform as it isUnitpassnot runnot runnot run
a streamed response > puts the error card of a throwing chunk source in the slot it was givenUnitpassnot runnot runnot run
a streamed response > sets cache-control: no-transform when the page set no cache-controlUnitpassnot runnot runnot run
bake_yield > bakes a region still waiting on its promise (a sync generator yields it unresolved)Unitpassnot runnot runnot run
packages/router/test/router-visitor.test.ts
anonymousVisitor() > mints a different random id for each new visitorUnitpassnot runnot runnot run
anonymousVisitor() > mints an id into the cookie jar once, then hands the same id backUnitpassnot runnot runnot run
anonymousVisitor() > with no cookie jar to write, sets the cookie on the response headersUnitpassnot runnot runnot run
packages/router/test/visitor.test.ts
anonymousVisitor > a first visit mints the id into the cookie and returns it as `vid`Unitpassnot runnot runnot run
anonymousVisitor > a returning visitor is `{ vid, anonymous }`, with no `sub`Unitpassnot runnot runnot run