Something went wrong. Try again.
Web frontend and supporting services for lance.blue
Something went wrong. Try again.
2.7 kB · 70 lines
JavaScript
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071/** * A finished match links to its report. * * The list predates the report screen, so a match that was over showed a dash * where the way in belongs: the record of what was played had no way to read * any of it. Structural, like the rest of these — there is no DOM under * `npm test`, and a wrong address renders perfectly well. * * Run with `npm test`. */import { test } from "node:test";import assert from "node:assert/strict";import { readFile } from "node:fs/promises";import { fileURLToPath } from "node:url";
const web = fileURLToPath(new URL("../", import.meta.url));const list = await readFile(`${web}src/screens/match-list.ts`, "utf8");const account = await readFile(`${web}src/account.ts`, "utf8");
test("a match that is over offers its report", () => { assert.match( list, /match\.status === "over"[\s\S]{0,300}reportUrl\(view, match\.matchId\)/, "a finished match no longer links to its report", );});
test("the report is read from this site, with the reader in it", () => { // /reports/* is a behaviour on the site's own distribution, which is what // makes a shared match a lance.blue link rather than an api. one; the // perspective is what makes the page say who won in the second person. // // The subject's handle, not the reader's: a row on somebody's /matches page // is a line in their record, and reporting it from a visitor's point of view // would name a match that visitor was never in. assert.match(list, /`\/reports\/\$\{matchId\}/); assert.match( list, /perspective=\$\{encodeURIComponent\(view\.subject\.handle\)\}/, );});
test("a failed match offers nothing to read", () => { // It never produced a result, so there is no report behind the link: the // report branch tests one status by name rather than reusing isFinished, // which counts `failed` as finished too. assert.match(list, /match\.status === "over"/); assert.ok( !/isFinished\(match\)[\s\S]{0,120}reportUrl/.test(list), "the report link was widened to every finished match, failures included", );});
test("Your matches goes to the player's own record, at an address", () => { // A path and not a hash. The hash it used to be stopped resolving the day // Operations left the masthead, because the router's set of hash routes is // derived from the destinations; an address cannot go that way. assert.match( account, /link\(matchesHref\(session\), "Your matches"\)/, "the account menu points somewhere else again", );});
test("the account menu does not name the camo tab a second time", () => { assert.ok( !/"Your camo"/.test(account), "Camo is a destination in the masthead; the menu had it twice", );});