30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { readFile } from "node:fs/promises";
|
|
import test from "node:test";
|
|
|
|
const homePageSource = await readFile(
|
|
new URL("../src/pages/HomePage.tsx", import.meta.url),
|
|
"utf8",
|
|
);
|
|
|
|
test("keeps past match history focused on the five summary columns", () => {
|
|
const colGroup = sourceForFunction("HistoryTableColGroup");
|
|
const header = sourceForFunction("HistoryTableHeader");
|
|
const skeleton = sourceForFunction("HistoryRecordsSkeleton");
|
|
|
|
assert.equal(colGroup.match(/<col(?:\s|\/|>)/g)?.length, 5);
|
|
assert.doesNotMatch(header, />결과<\/th>/);
|
|
assert.doesNotMatch(homePageSource, /공식 결과/);
|
|
assert.doesNotMatch(skeleton, /1팀 승리/);
|
|
assert.match(homePageSource, /colSpan=\{5\}/);
|
|
});
|
|
|
|
function sourceForFunction(name: string): string {
|
|
const start = homePageSource.indexOf(`function ${name}(`);
|
|
assert.notEqual(start, -1, `${name} should exist`);
|
|
|
|
const nextFunction = homePageSource.indexOf("\nfunction ", start + 1);
|
|
assert.notEqual(nextFunction, -1, `${name} should have a following function`);
|
|
return homePageSource.slice(start, nextFunction);
|
|
}
|