Skip to content
31 linesCodeBlameRaw
1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { CHECKS, pageText, verdict } from "./smoke.mjs";
5
6test("a page's text leaves out scripts, styles and tags", () => {
7 const html = `<html><style>.a{}</style><script>var x="Create account"</script><h1>Create your&nbsp;<b>account</b></h1></html>`;
8 assert.equal(pageText(html), "Create your account");
9 assert.equal(pageText("<p>Don&#x27;t</p>"), "Don't");
10});
11
12test("a check passes on its status with every phrase on the page", () => {
13 const check = { path: "/register", expect: ["Create your account", "Create account"] };
14 assert.equal(verdict(check, 200, "<h1>Create your account</h1><button>Create account</button>"), null);
15 assert.equal(verdict(check, 500, ""), "answered 500, expected 200");
16 assert.equal(verdict(check, 200, "<h1>Create your account</h1>"), 'missing "Create account"');
17});
18
19test("a phrase only inside a script does not count", () => {
20 const check = { path: "/", expect: ["Create account"] };
21 assert.equal(verdict(check, 200, `<script>"Create account"</script>`), 'missing "Create account"');
22});
23
24test("the sign-up check sends an address identity refuses before writing or counting", () => {
25 const signUp = CHECKS.find((check) => check.form);
26 assert.ok(signUp);
27 assert.equal(signUp.path, "/register");
28 assert.ok(!signUp.form.email.includes("@"), "never a real-looking address, so nothing is kept");
29 assert.equal(signUp.status, 422);
30 assert.equal(verdict(signUp, 422, "<p>Enter a valid email address.</p>"), null);
31});