Tests / @ogygia/router
@ogygia/router
Version 0.14.0 latest
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
| Test | Kind | Node | Chromium | Firefox | WebKit |
|---|---|---|---|---|---|
packages/router/e2e/island-pkg.spec.ts | |||||
| browser: package-internal island, deferred island, shipped route, .ts-table page all hydrate | End to end | not run | pass | pass | pass |
| SSR: all three surfaces render server HTML | End to end | not run | pass | pass | pass |
packages/router/e2e/router-seed.spec.ts | |||||
| a router page whose islands read nothing ships no seed | End to end | not run | pass | pass | pass |
| an island that reads page.data gets it, shaped to the key it reads | End to end | not run | pass | pass | pass |
packages/router/e2e/stream-page.spec.ts | |||||
| browser: payload swapped in, template consumed, LATE island interactive + SPA-swap twin | End to end | not run | pass | pass | pass |
| late regions: a late region holding another promise region streams both | End to end | not run | pass | pass | pass |
| late regions: a load promise-of-region resolves down the SAME response | End to end | not run | pass | pass | pass |
| timing: the first chunk does NOT wait for the slow yield | End to end | not run | pass | pass | pass |
| wire: skeleton before payload, payload inside an inert template | End to end | not run | pass | pass | pass |
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)#1142 | Unit | pass | not run | not run | not 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 refused | Unit | pass | not run | not run | not run |
| fill, read back through the URL parser > gives back the params as filled, or refuses them | Unit | pass | not run | not run | not run |
| fill, read back through the URL parser > refuses a param that would fill a whole segment with a dot segment | Unit | pass | not run | not run | not 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’s | Unit | pass | not run | not run | not run |
| route config × programmatic router > a claimed-but-unset path shadows the file world; an unclaimed one falls through to it | Unit | pass | not run | not run | not run |
| route config × programmatic router > a page that sets nothing and an unmatched path both answer undefined (the default applies) | Unit | pass | not run | not run | not run |
| route config × programmatic router > dynamic patterns match like dispatch | Unit | pass | not run | not run | not run |
| route config × programmatic router > endpoints are not pages: claimed, nothing set, whatever the table says | Unit | pass | not run | not run | not run |
| route config × programmatic router > nested layouts: the innermost wins over an outer one | Unit | pass | not run | not run | not run |
| route config × programmatic router > page > layout > table — the deepest level wins | Unit | pass | not run | not run | not run |
| route config × programmatic router > re-registering the same table REPLACES its matcher (dev re-evaluation), never shadows it | Unit | pass | not run | not run | not run |
| route config × programmatic router > the merge is per key: a deeper config without the key keeps the outer value | Unit | pass | not run | not run | not run |
| route config × programmatic router > two mounted tables: the one that claims the path answers | Unit | pass | not run | not run | not 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 list | Unit | pass | not run | not run | not run |
| a page’s verbs > an empty actions table takes no POST | Unit | pass | not run | not run | not run |
| a page’s verbs > OPTIONS on a page answers 204 with the verbs it takes | Unit | pass | not run | not run | not run |
| c.visitor > an anonymous answer is remembered too: the resolver runs once | Unit | pass | not run | not run | not run |
| c.visitor > is worked out once per request, however often it is read | Unit | pass | not run | not run | not run |
| c.visitor > signed claims a shell attached win, and the resolver never runs | Unit | pass | not run | not run | not run |
| late regions > a rejected one streams its error card once, and the rest still come | Unit | pass | not run | not run | not run |
| late regions > stream each once, in the order they finish, and then end | Unit | pass | not run | not run | not 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 browser | Unit | pass | not run | not run | not 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 undefined | Unit | pass | not run | not run | not run |
| api() — the typed endpoint client > a null return answers 204 → resolves undefined | Unit | pass | not run | not run | not run |
| api() — the typed endpoint client > a schema 400 throws ApiError carrying the issues body | Unit | pass | not run | not run | not run |
| api() — the typed endpoint client > an unmatched path throws ApiError 404 | Unit | pass | not run | not run | not run |
| api() — the typed endpoint client > fills the pattern, carries the query, parses the typed payload | Unit | pass | not run | not run | not run |
| api() — the typed endpoint client > POSTs the schema-typed body; the payload comes back typed | Unit | pass | not run | not run | not run |
packages/router/test/router-define.test.ts | |||||
| layout() > prepends itself to each page chain, outermost first, and passes endpoints through as they are | Unit | pass | not run | not run | not run |
| load() inside one request > a failed load is the request’s failure: the next call in it gets the same, without a run | Unit | pass | not run | not run | not run |
| load() inside one request > refuses a load asked for after its request ended, with the reason the request ended | Unit | pass | not run | not run | not run |
| page() actions > keeps an action() wrapper as it is and wraps a bare function | Unit | pass | not run | not run | not run |
packages/router/test/router-dispatch.test.ts | |||||
| dispatch — base, slash, miss > 308-canonicalizes a trailing slash under slash:never | Unit | pass | not run | not run | not run |
| dispatch — base, slash, miss > runs miss for an unmatched path under base | Unit | pass | not run | not run | not run |
| dispatch — base, slash, miss > strips base, returns null for out-of-base | Unit | pass | not run | not run | not run |
| dispatch — c.setHeaders reaches router-built responses > applies collected headers to the built response | Unit | pass | not run | not run | not run |
| dispatch — c.setHeaders reaches router-built responses > never clobbers headers the handler set explicitly | Unit | pass | not run | not run | not run |
| dispatch — endpoints, params, verbs > dispatches verbs, 405s the rest with allow, answers OPTIONS | Unit | pass | not run | not run | not run |
| dispatch — endpoints, params, verbs > falls through (null) on no match when unbased | Unit | pass | not run | not run | not run |
| dispatch — endpoints, params, verbs > routes GET endpoints with params ([slug], [...rest]) | Unit | pass | not run | not run | not run |
| dispatch — the trailing-slash redirect stays on the site > slash:always on "//other.example" redirects to a path on this host | Unit | pass | not run | not run | not run |
| dispatch — the trailing-slash redirect stays on the site > slash:always on "/\\other.example" redirects to a path on this host | Unit | pass | not run | not run | not run |
| dispatch — the trailing-slash redirect stays on the site > slash:never on "///other.example/x/" redirects to a path on this host | Unit | pass | not run | not run | not run |
| dispatch — the trailing-slash redirect stays on the site > slash:never on "//other.example/" redirects to a path on this host | Unit | pass | not run | not run | not run |
| dispatch — thrown redirect / error > error() from an endpoint → JSON error | Unit | pass | not run | not run | not run |
| dispatch — thrown redirect / error > redirect() → a redirect response | Unit | pass | not run | not run | not run |
| entries — prerender param sets for dynamic patterns > fills declared entries into the crawl list; undeclared dynamics are skipped | Unit | pass | not run | not run | not run |
| href — rename-safe links off the table keys > fills params + prefixes base | Unit | pass | not run | not run | not run |
| layout names — one name, one layout, across the table > the same layout reused under its one name is fine | Unit | pass | not run | not run | not run |
| layout names — one name, one layout, across the table > two different layouts with the same name throw when the table is built | Unit | pass | not run | not run | not run |
| loads — memoization + parent-sharing (no waterfall, no waste) > a shared load runs ONCE per request even when two loads await it | Unit | pass | not run | not run | not run |
| loads — memoization + parent-sharing (no waterfall, no waste) > memo is per-request (a second request re-runs) | Unit | pass | not run | not run | not run |
| miss — HTML boundary for page requests > unmatched NON-HTML request keeps the JSON 404 (fetch/API callers) | Unit | pass | not run | not run | not run |
| miss — HTML boundary for page requests > unmatched page GET under a base renders the root error page as HTML 404 | Unit | pass | not run | not run | not 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 one | Unit | pass | not run | not run | not run |
| pages — a thrown error finds its boundary > a layout load that throws synchronously is found as the failed layer too | Unit | pass | not run | not run | not 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 layout | Unit | pass | not run | not run | not run |
| pages — a thrown error finds its boundary > a page load’s error renders the innermost error page inside every layout, with their data | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not run |
| pages — a thrown error finds its boundary > an action’s error renders the innermost error page, every layout’s load having run | Unit | pass | not run | not run | not run |
| pages — a thrown error finds its boundary > an error page does not run the load that failed again | Unit | pass | not run | not run | not run |
| pages — a thrown error finds its boundary > with no error page anywhere, a page’s error answers JSON | Unit | pass | not run | not run | not run |
| pages — the branch’s loads > a page load that returns a Response is the answer: nothing renders | Unit | pass | not run | not run | not run |
| pages — the branch’s loads > the layouts’ and the page’s loads all run before any of them ends (no waterfall) | Unit | pass | not run | not run | not run |
| pages — the branch’s loads > the loads’ data merges in branch order: the page’s wins over its layout’s | Unit | pass | not run | not run | not run |
| the table-wide load — a guard before every route > a Response it returns is the answer: the route never runs | Unit | pass | not run | not run | not run |
| the table-wide load — a guard before every route > its thrown redirect gates an endpoint too | Unit | pass | not run | not run | not run |
packages/router/test/router-layout-chain.test.ts | |||||
| LayoutChain > hands a deferred page's fallback to it as its ogygiaFallback snippet, with the data | Unit | pass | not run | not run | not run |
| LayoutChain > nests the layouts outermost first around the page, each reading the data | Unit | pass | not run | not run | not 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)#1139 | Unit | pass | not run | not run | not run |
| router pattern matching > distinguishes dot-suffixed and nested variants (the profiler /report cases) | Unit | pass | not run | not run | not run |
| router pattern matching > fill() drops the segment of an empty optional or rest param, as Kit does | Unit | pass | not run | not run | not run |
| router pattern matching > fill() keeps the slashes of a rest value and encodes each of its segments, as Kit does | Unit | pass | not run | not run | not run |
| router pattern matching > fill() puts URL-encoded params into every token kind, and nothing for a missing one | Unit | pass | not run | not run | not run |
| router pattern matching > handles [...rest] (may be empty) and [[optional]] | Unit | pass | not run | not run | not run |
| router pattern matching > hands back a param with a malformed %xx as it was, instead of throwing | Unit | pass | not run | not run | not run |
| router pattern matching > is trailing-slash-insensitive and decodes params | Unit | pass | not run | not run | not run |
| router pattern matching > matches root, static, and params | Unit | pass | not run | not run | not run |
| router pattern matching > orders overlapping routes static > param > rest | Unit | pass | not run | not run | not run |
| router pattern matching > REGRESSION: an empty-matching [...rest] must not shadow shorter routes | Unit | pass | not run | not run | not run |
| router pattern matching > rejects a segment with a stray bracket left after its valid [param] groups | Unit | pass | not run | not run | not run |
| router pattern matching > rejects malformed patterns loudly | Unit | pass | not run | not run | not run |
| router pattern matching takes time in line with the path > a param may hold the first character of the literal after it (#833)#833 | Unit | pass | not run | not run | not run |
| router pattern matching takes time in line with the path > a path longer than any route can mean matches nothing | Unit | pass | not run | not run | not run |
| router pattern matching takes time in line with the path > a segment with several params answers a long path that almost matches at once | Unit | pass | not run | not run | not run |
| router pattern matching takes time in line with the path > every short path splits as SvelteKit lazy params would (#833)#833 | Unit | pass | not run | not run | not 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 rest | Unit | pass | not run | not run | not 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)#833 | Unit | pass | not run | not run | not run |
packages/router/test/router-plugin.test.ts | |||||
| router() marks every module importing @ogygia/router as a page module | Unit | pass | not run | not run | not 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#1759 | Unit | pass | not run | not run | not run |
| c.json() and c.text() keep the headers they are given (#1759) > header pairs reach the response by name, not by index#1759 | Unit | pass | not run | not run | not run |
| c.json() and c.text() keep the headers they are given (#1759) > json keeps its no-store default next to the given headers#1759 | Unit | pass | not run | not run | not run |
| c.json() and c.text() keep the headers they are given (#1759) > the caller's content type replaces the default, whatever its case#1759 | Unit | pass | not run | not run | not 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]#1139 | Unit | pass | not run | not run | not run |
| overlapping patterns resolve as Kit resolves them (#1139) > /[p] and /[q] at /b is /[q]#1139 | Unit | pass | not run | not run | not run |
| overlapping patterns resolve as Kit resolves them (#1139) > /[p].json and /[p]/[[o]] at /1.json is /[p].json#1139 | Unit | pass | not run | not run | not run |
| overlapping patterns resolve as Kit resolves them (#1139) > /[p]/[...r] and /[[o]]/[[oz]] at /b is /[p]/[...r]#1139 | Unit | pass | not run | not run | not run |
| overlapping patterns resolve as Kit resolves them (#1139) > /a and /[[lang]]/a at /a is /a#1139 | Unit | pass | not run | not run | not run |
| overlapping patterns resolve as Kit resolves them (#1139) > /a/[...r] and /[p]/[q] at /a/b is /a/[...r]#1139 | Unit | pass | not run | not run | not run |
| overlapping patterns resolve as Kit resolves them (#1139) > /b and /b/[[o]] at /b is /b#1139 | Unit | pass | not run | not run | not run |
| overlapping patterns resolve as Kit resolves them (#1139) > /b/[...r] and /[[o]]/b/[...r] at /b is /b/[...r]#1139 | Unit | pass | not run | not run | not run |
| the order a table is written in never changes a pick > two patterns that both match a path: the same winner either way round | Unit | pass | not run | not run | not run |
packages/router/test/router-schema.test.ts | |||||
| endpoint body schema (POST/PUT/PATCH → c.input) > 400s a bad body with the issues | Unit | pass | not run | not run | not run |
| endpoint body schema (POST/PUT/PATCH → c.input) > 400s a non-JSON body | Unit | pass | not run | not run | not 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) | Unit | pass | not run | not run | not run |
| endpoint body schema (POST/PUT/PATCH → c.input) > validates the JSON body and types c.input | Unit | pass | not run | not run | not run |
| page-level search schema (typed search params → c.search, bad → 400) > 400s bad input with the issues, before any load runs | Unit | pass | not run | not run | not run |
| page-level search schema (typed search params → c.search, bad → 400) > applies the schema default when the param is absent (lenient) | Unit | pass | not run | not run | not run |
| page-level search schema (typed search params → c.search, bad → 400) > coerces good input into the typed c.search (string → number) | Unit | pass | not run | not run | not 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 error | Unit | pass | not run | not run | not run |
| a source whose cleanup fails as the visitor leaves > a source a merged stream holds: request_cleanup_failed, with the error | Unit | pass | not run | not run | not run |
| a streamed page the visitor left (#284) > cancelling a merged, drained stream ends every source it holds#284 | Unit | pass | not run | not run | not run |
| a streamed page the visitor left (#284) > cancelling the body ends the page generator and renders nothing more#284 | Unit | pass | not run | not run | not 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 space | Unit | pass | not run | not run | not run |
| the late boot in a streamed page > lands in the head, not in a comment before it that names the end tag | Unit | pass | not run | not run | not run |
packages/router/test/router-stream.test.ts | |||||
| a streamed response > adds no-transform to a cache-control the page set, keeping what it said | Unit | pass | not run | not run | not run |
| a streamed response > drops a content-length the page response carried, so the stream is not cut short | Unit | pass | not run | not run | not run |
| a streamed response > ends the page generator when the request it belongs to ends | Unit | pass | not run | not run | not run |
| a streamed response > leaves a cache-control that already says no-transform as it is | Unit | pass | not run | not run | not run |
| a streamed response > puts the error card of a throwing chunk source in the slot it was given | Unit | pass | not run | not run | not run |
| a streamed response > sets cache-control: no-transform when the page set no cache-control | Unit | pass | not run | not run | not run |
| bake_yield > bakes a region still waiting on its promise (a sync generator yields it unresolved) | Unit | pass | not run | not run | not run |
packages/router/test/router-visitor.test.ts | |||||
| anonymousVisitor() > mints a different random id for each new visitor | Unit | pass | not run | not run | not run |
| anonymousVisitor() > mints an id into the cookie jar once, then hands the same id back | Unit | pass | not run | not run | not run |
| anonymousVisitor() > with no cookie jar to write, sets the cookie on the response headers | Unit | pass | not run | not run | not run |
packages/router/test/visitor.test.ts | |||||
| anonymousVisitor > a first visit mints the id into the cookie and returns it as `vid` | Unit | pass | not run | not run | not run |
| anonymousVisitor > a returning visitor is `{ vid, anonymous }`, with no `sub` | Unit | pass | not run | not run | not run |