← tests

parameters

Router captures, with segment depth held constant, each bound as an integer and echoed.

Comparable across every framework. The static row holds the depth, so the capture rows minus it is the router capturing rather than the router matching.

A value written {run.name} is drawn once per run and never given to the framework, so it cannot answer from a table.

testheftrequestbasewhat differs from the base
parameters.static1GET /parameters/static/segment/literaljson.smalla deeper static route, with no captures in it
parameters.one1GET /parameters/{run.one}/segment/literalparameters.staticone more path segment the router has to capture
parameters.two1GET /parameters/{run.one}/with-second/{run.two}parameters.oneone more path segment the router has to capture
parameters.three1GET /parameters/{run.one}/{run.two}/{run.three}parameters.twoone more path segment the router has to capture

parameters.static

heft 1

base json.smallbase of parameters.one

Four static segments and no captures. This holds the route depth constant for the two rows that capture, so subtracting it leaves the router capturing rather than the router matching a longer path.

Request

GET /parameters/static/segment/literal

No body.

Expected response

HTTP 200

payload items.small

{"size":"small","count":1,"items":[{"id":1,"name":"slate-lamp-6647","category":"tools","priceCents":18928,"inStock":true}]}

Compared as parsed JSON, so key order and how a number is written do not matter.

Test source, tests/parameters/static.ts
tests/parameters/static.tsopen on GitHub →
import { performanceTest } from "#kit";
import { items } from "#payloads";

const path = "/parameters/static/segment/literal";

export default performanceTest({
  id: { family: "parameters", name: "static" },
  path,
  base: "json.small",
  varies: "depth",
  heft: 1,
  about:
    "Four static segments and no captures. This holds the route depth " +
    "constant for the two rows that capture, so subtracting it leaves the " +
    "router capturing rather than the router matching a longer path.",

  request: (c) => c.get(path).okWith(items.small),
});

parameters.one

heft 1

base parameters.staticbase of items.read, parameters.two

One segment captured, bound as an integer and written back. The value is drawn per run, so a framework that answered from a table would have had to know it in advance, and the echo is checked against what was sent.

Request

GET /parameters/{run.one}/segment/literal

No body.

Expected response

HTTP 200

payload items.small

{"size":"small","count":1,"items":[{"id":1,"name":"slate-lamp-6647","category":"tools","priceCents":18928,"inStock":true}],"echo":{"one":{run.one}}}

Compared as parsed JSON, so key order and how a number is written do not matter.

Test source, tests/parameters/one.ts
tests/parameters/one.tsopen on GitHub →
import { performanceTest } from "#kit";
import { items } from "#payloads";

const path = "/parameters/{run.one}/segment/literal";

export default performanceTest({
  id: { family: "parameters", name: "one" },
  path,
  base: "parameters.static",
  varies: "captures",
  heft: 1,
  about:
    "One segment captured, bound as an integer and written back. The value is " +
    "drawn per run, so a framework that answered from a table would have had " +
    "to know it in advance, and the echo is checked against what was sent.",

  request: (c) => c.get(`/parameters/${c.run.one}/segment/literal`).okWith(items.small, { echo: ["one"] }),
});

parameters.two

heft 1

base parameters.onebase of parameters.three

The same depth with a second capture in it. Read against parameters.one, the difference is one more segment the router has to capture and one more value the framework has to convert.

Request

GET /parameters/{run.one}/with-second/{run.two}

No body.

Expected response

HTTP 200

payload items.small

{"size":"small","count":1,"items":[{"id":1,"name":"slate-lamp-6647","category":"tools","priceCents":18928,"inStock":true}],"echo":{"one":{run.one},"two":{run.two}}}

Compared as parsed JSON, so key order and how a number is written do not matter.

Test source, tests/parameters/two.ts
tests/parameters/two.tsopen on GitHub →
import { performanceTest } from "#kit";
import { items } from "#payloads";

const path = "/parameters/{run.one}/with-second/{run.two}";

export default performanceTest({
  id: { family: "parameters", name: "two" },
  path,
  base: "parameters.one",
  varies: "captures",
  heft: 1,
  about:
    "The same depth with a second capture in it. Read against parameters.one, " +
    "the difference is one more segment the router has to capture and one " +
    "more value the framework has to convert.",

  request: (c) =>
    c.get(`/parameters/${c.run.one}/with-second/${c.run.two}`).okWith(items.small, { echo: ["one", "two"] }),
});

parameters.three

heft 1

base parameters.two

The same depth with three of its four segments captured, which leaves parameters as the only static one. Read against parameters.two, the difference is a third segment the router has to capture and a third value the framework has to convert.

Request

GET /parameters/{run.one}/{run.two}/{run.three}

No body.

Expected response

HTTP 200

payload items.small

{"size":"small","count":1,"items":[{"id":1,"name":"slate-lamp-6647","category":"tools","priceCents":18928,"inStock":true}],"echo":{"one":{run.one},"two":{run.two},"three":{run.three}}}

Compared as parsed JSON, so key order and how a number is written do not matter.

Test source, tests/parameters/three.ts
tests/parameters/three.tsopen on GitHub →
import { performanceTest } from "#kit";
import { items } from "#payloads";

const path = "/parameters/{run.one}/{run.two}/{run.three}";

export default performanceTest({
  id: { family: "parameters", name: "three" },
  path,
  base: "parameters.two",
  varies: "captures",
  heft: 1,
  about:
    "The same depth with three of its four segments captured, which leaves " +
    "parameters as the only static one. Read against parameters.two, the " +
    "difference is a third segment the router has to capture and a third " +
    "value the framework has to convert.",

  request: (c) =>
    c.get(`/parameters/${c.run.one}/${c.run.two}/${c.run.three}`).okWith(items.small, { echo: ["one", "two", "three"] }),
});