Skip to main content

max / quasi

2.5 KB · 68 lines History Blame Raw
1 <!doctype html>
2 <!--
3 The scripts this crate ships, run in a browser.
4
5 `4e7f8380`, decided 2026-08-30. Twelve `.js` files under `src/` are emitted
6 into every described document and not one line of them was executed by a
7 test: the Rust tests assert that the `<script src>` is in the head, that
8 `without_htmx` drops it, and that the constant and the default path agree.
9 All three are true of a file that does nothing.
10
11 This is the shape htmx tests itself in, and copying it is not incidental:
12 these scripts are htmx handlers, and htmx exists to exploit real browser
13 behaviour. mocha and chai load as script tags, then the script under test
14 loads **as shipped**, then the assertions. Open this file in a browser to
15 read a failure; run `run.py` for a verdict.
16
17 Each script is a bare IIFE that exports nothing and installs its own
18 listeners, which is the right shape for a `<script>` and the wrong shape for
19 every import-and-call runner. Loading the page runs them; the tests drive the
20 DOM. That is what makes this the cheap option rather than the thorough one:
21 no npm, no package.json, no node_modules, no bundler, and no edit to the
22 twelve files.
23 -->
24 <html><head><meta charset="utf-8"><title>pending</title>
25 <link rel="stylesheet" href="vendor/mocha.css">
26 </head>
27 <body>
28 <div id="mocha"></div>
29 <div id="fixture"></div>
30
31 <script src="vendor/mocha.js"></script>
32 <script src="vendor/chai.js"></script>
33 <script>
34 mocha.setup("bdd");
35 window.expect = chai.expect;
36
37 /** Put this markup in the fixture and hand back the element that holds it. */
38 window.fixture = (html) => {
39 const held = document.getElementById("fixture");
40 held.innerHTML = html;
41 return held;
42 };
43 </script>
44
45 <!--
46 The shipped scripts, from where they ship, unmodified. A copy here would be a
47 second file to keep in step, and the first thing it would stop catching is a
48 change to the real one.
49 -->
50 <script src="../../src/outline.js"></script>
51 <script src="../../src/focus.js"></script>
52
53 <script src="outline.test.js"></script>
54 <script src="focus.test.js"></script>
55
56 <script>
57 // The verdict, in the one place a driver can read without a protocol of its
58 // own. `run.py` polls the title and reads `#mocha` for the detail.
59 const runner = mocha.run();
60 let failed = 0;
61 runner.on("fail", () => { failed += 1; });
62 runner.on("end", () => {
63 const { passes, tests } = runner.stats;
64 document.title = `${failed === 0 ? "PASS" : "FAIL"} ${passes}/${tests}`;
65 });
66 </script>
67 </body></html>
68