From 296904ed17657b27b12837f7337e6601746ce32f Mon Sep 17 00:00:00 2001 From: Kat <00-kat@proton.me> Date: Sun, 29 Mar 2026 05:43:56 +1100 Subject: [PATCH] TODO: actually write tests lol --- cmd/pkgserver/test_ui.go | 7 +++ cmd/pkgserver/ui_test/all_tests.ts | 2 +- cmd/pkgserver/ui_test/sample_tests.ts | 85 --------------------------- 3 files changed, 8 insertions(+), 86 deletions(-) delete mode 100644 cmd/pkgserver/ui_test/sample_tests.ts diff --git a/cmd/pkgserver/test_ui.go b/cmd/pkgserver/test_ui.go index 574c8716..35af9376 100644 --- a/cmd/pkgserver/test_ui.go +++ b/cmd/pkgserver/test_ui.go @@ -8,7 +8,14 @@ import ( "net/http" ) +// Always remove ui_test/ui; if the previous tsc run failed, the rm never +// executes. + +//go:generate sh -c "rm -r ui_test/ui/ 2>/dev/null || true" +//go:generate mkdir ui_test/ui +//go:generate sh -c "cp ui/static/*.ts ui_test/ui/" //go:generate tsc --outDir ui_test/static -p ui_test +//go:generate rm -r ui_test/ui/ //go:generate sass ui_test/lib/ui.scss ui_test/static/style.css //go:generate cp ui_test/lib/ui.html ui_test/static/index.html //go:generate sh -c "cd ui_test/lib && cp *.svg ../static/" diff --git a/cmd/pkgserver/ui_test/all_tests.ts b/cmd/pkgserver/ui_test/all_tests.ts index 69805f44..e26fe98b 100644 --- a/cmd/pkgserver/ui_test/all_tests.ts +++ b/cmd/pkgserver/ui_test/all_tests.ts @@ -1,2 +1,2 @@ // Import all test files to register their test suites. -import "./sample_tests.js"; +import "./index_test.js"; diff --git a/cmd/pkgserver/ui_test/sample_tests.ts b/cmd/pkgserver/ui_test/sample_tests.ts deleted file mode 100644 index 8d1b5526..00000000 --- a/cmd/pkgserver/ui_test/sample_tests.ts +++ /dev/null @@ -1,85 +0,0 @@ -import { NoOpReporter, TestRegistrar, context, group, suite, test } from "./lib/test.js"; - -suite("dog", [ - group("tail", [ - test("wags when happy", (t) => { - if (0 / 0 !== Infinity / Infinity) { - t.fatal("undefined must not be defined"); - } - }), - test("idle when down", (t) => { - t.log("test test"); - t.error("dog whining noises go here"); - }), - ]), - test("likes headpats", (t) => { - if (2 !== 2) { - t.error("IEEE 754 violated: 2 is NaN"); - } - }), - context("near cat", [ - test("is ecstatic", (t) => { - if (("b" + "a" + + "a" + "a").toLowerCase() === "banana") { - t.error("🍌🍌🍌"); - t.error("🍌🍌🍌"); - t.error("🍌🍌🍌"); - t.failNow(); - } - }), - test("playfully bites cats' tails", (t) => { - t.log("arf!"); - throw new Error("nom"); - }), - ]), -]); - -suite("cat", [ - test("likes headpats", (t) => { - t.log("meow"); - }), - test("owns skipping rope", (t) => { - t.skip("this cat is stuck in your machine!"); - t.log("never logged"); - }), - test("tester tester", (t) => { - const r = new TestRegistrar(); - r.suite("explod", [ - test("with yarn", (t) => { - t.log("YAY"); - }), - ]); - const reporter = new NoOpReporter(); - r.run(reporter); - if (reporter.suites.length !== 1) { - t.fatal(`incorrect number of suites registered got=${reporter.suites.length} want=1`); - } - const suite = reporter.suites[0]; - if (suite.name !== "explod") { - t.error(`suite name incorrect got='${suite.name}' want='explod'`); - } - if (suite.children.length !== 1) { - t.fatal(`incorrect number of suite children got=${suite.children.length} want=1`); - } - const test_ = suite.children[0]; - if (test_.name !== "with yarn") { - t.error(`incorrect test name got='${test_.name}' want='with yarn'`); - } - if ("children" in test_) { - t.error(`expected leaf node, got group of ${test_.children.length} children`); - } - if (!reporter.finalized) t.error(`expected reporter to have been finalized`); - if (reporter.results.length !== 1) { - t.fatal(`incorrect result count got=${reporter.results.length} want=1`); - } - const result = reporter.results[0]; - if (!(result.path.length === 2 && - result.path[0] === "explod" && - result.path[1] === "with yarn")) { - t.error(`incorrect result path got=${result.path} want=["explod", "with yarn"]`); - } - if (result.state !== "success") t.error(`expected test to succeed`); - if (!(result.logs.length === 1 && result.logs[0] === "YAY")) { - t.error(`incorrect result logs got=${result.logs} want=["YAY"]`); - } - }), -]);