diff options
Diffstat (limited to 'tests/js')
-rw-r--r-- | tests/js/accretion.mjs | 18 | ||||
-rw-r--r-- | tests/js/db.mjs | 15 | ||||
-rw-r--r-- | tests/js/escape.mjs | 9 | ||||
-rw-r--r-- | tests/js/hero.mjs | 19 | ||||
-rw-r--r-- | tests/js/ircd.mjs | 5 | ||||
-rw-r--r-- | tests/js/utils.mjs | 4 | ||||
-rw-r--r-- | tests/js/web.mjs | 5 |
7 files changed, 39 insertions, 36 deletions
diff --git a/tests/js/accretion.mjs b/tests/js/accretion.mjs index 3ea90c3..a0fbb66 100644 --- a/tests/js/accretion.mjs +++ b/tests/js/accretion.mjs @@ -2,27 +2,29 @@ import assert from "node:assert/strict"; import sqlite from "../../src/sqlite.cjs"; -import { runTests } from "../runner.mjs"; -import { promisifyDb, open } from "../../src/db.mjs"; -import { runMigrations } from "../../src/accretion.mjs"; +import * as runner from "../runner.mjs"; +import * as db from "../../src/db.mjs"; +import { + runMigrations, +} from "../../src/accretion.mjs"; const test_runMigrations = t => { t.start("runMigrations()"); t.test("running twice is a noop", async () => { - const db = await open(":memory:"); - const migrationsFn = () => db.all("SELECT filename FROM migrations;"); + const handle = await db.open(":memory:"); + const migrationsFn = () => handle.all("SELECT filename FROM migrations;"); assert.rejects( migrationsFn, { message: "SQLITE_ERROR: no such table: migrations" }, ); - await runMigrations(db); + await runMigrations(handle); const filled = await migrationsFn(); - await runMigrations(db); + await runMigrations(handle); const unchanged = await migrationsFn(); assert.deepEqual(filled, unchanged); @@ -30,6 +32,6 @@ const test_runMigrations = t => { }; -await runTests([ +await runner.runTests([ test_runMigrations, ]); diff --git a/tests/js/db.mjs b/tests/js/db.mjs index fcea535..c6c5c85 100644 --- a/tests/js/db.mjs +++ b/tests/js/db.mjs @@ -2,8 +2,13 @@ import assert from "node:assert/strict"; import sqlite from "../../src/sqlite.cjs"; -import { runTests } from "../runner.mjs"; -import { promisifyDb, open, db, init } from "../../src/db.mjs"; +import * as runner from "../runner.mjs"; +import { + promisifyDb, + open, + handle, + init, +} from "../../src/db.mjs"; const test_promisifyDb = t => { @@ -88,16 +93,16 @@ const test_init = t => { t.start("init()"); t.test("we only know how to deal with 1 database", async () => { await init(); - const ref1 = db; + const ref1 = handle; await init(); - const ref2 = db; + const ref2 = handle; assert.notDeepEqual(ref1, ref2); }); }; -await runTests([ +await runner.runTests([ test_promisifyDb, test_open, test_init, diff --git a/tests/js/escape.mjs b/tests/js/escape.mjs index 2cad16a..8291391 100644 --- a/tests/js/escape.mjs +++ b/tests/js/escape.mjs @@ -1,6 +1,9 @@ import assert from "node:assert/strict"; -import { runTests } from "../runner.mjs"; -import { escape } from "../../src/escape.mjs"; + +import * as runner from "../runner.mjs"; +import { + escape, +} from "../../src/escape.mjs"; const test_escape = t => { t.start("escape()"); @@ -57,6 +60,6 @@ const test_escape = t => { }; -await runTests([ +await runner.runTests([ test_escape, ]); diff --git a/tests/js/hero.mjs b/tests/js/hero.mjs index 7b8a5cc..bc9d3d2 100644 --- a/tests/js/hero.mjs +++ b/tests/js/hero.mjs @@ -1,8 +1,8 @@ import assert from "node:assert/strict"; import http from "node:http"; -import { runTests } from "../runner.mjs"; -import { assocIn } from "../../src/utils.mjs"; +import * as runner from "../runner.mjs"; +import * as u from "../../src/utils.mjs"; import { normalizeSegments, pathToSegments, @@ -17,6 +17,7 @@ import { makeRequestListener, interceptorsFn, interceptors, + defaultInterceptors, chainInterceptors, wrapHandler, buildRoutes, @@ -274,7 +275,7 @@ const test_firstParamMatch = t => { }, }; - const tree2 = assocIn(tree1, [ "path", "param1", ":deeper", "" ], fn1); + const tree2 = u.assocIn(tree1, [ "path", "param1", ":deeper", "" ], fn1); assert.deepEqual( firstParamMatch(tree1, segments, params), @@ -298,7 +299,7 @@ const test_firstParamMatch = t => { }, }; - const tree2 = assocIn(tree1, ["user", ":aaa", ""], fn1); + const tree2 = u.assocIn(tree1, ["user", ":aaa", ""], fn1); assert.deepEqual( firstParamMatch(tree1, segments, params), @@ -1163,14 +1164,8 @@ const test_buildServer = t => { t.test("integrated application server", async () => { const socketPath = "./tests/hero-1.sock"; const pathHandler = req => ({ status: 200, body: "OK" }); - const globalInterceptors = [ - interceptors.serverError, - interceptors.contentType, - interceptors.requestId, - interceptors.logged, - ]; const routes = [ [ "GET", "/path", pathHandler ] ]; - const server = buildServer(routes, globalInterceptors); + const server = buildServer(routes, defaultInterceptors); await server.listen(socketPath); const response = await socketRequest(socketPath, "/path"); @@ -1181,7 +1176,7 @@ const test_buildServer = t => { }; -await runTests([ +await runner.runTests([ test_normalizeSegments, test_pathToSegments, test_hasPathParams, diff --git a/tests/js/ircd.mjs b/tests/js/ircd.mjs index e5eda66..d385a72 100644 --- a/tests/js/ircd.mjs +++ b/tests/js/ircd.mjs @@ -1,7 +1,6 @@ -import { runTests } from "../runner.mjs"; -import { } from "../../src/ircd.mjs"; +import * as runner from "../runner.mjs"; -await runTests([ +await runner.runTests([ ]); diff --git a/tests/js/utils.mjs b/tests/js/utils.mjs index e4f21d0..e2475b0 100644 --- a/tests/js/utils.mjs +++ b/tests/js/utils.mjs @@ -1,6 +1,6 @@ import assert from "node:assert/strict"; -import { runTests } from "../runner.mjs"; +import * as runner from "../runner.mjs"; import { eq, keys, @@ -291,7 +291,7 @@ const test_promisify = t => { }; -await runTests([ +await runner.runTests([ test_eq, test_keys, test_difference, diff --git a/tests/js/web.mjs b/tests/js/web.mjs index 00cce70..d385a72 100644 --- a/tests/js/web.mjs +++ b/tests/js/web.mjs @@ -1,7 +1,6 @@ -import { runTests } from "../runner.mjs"; -import { } from "../../src/web.mjs"; +import * as runner from "../runner.mjs"; -await runTests([ +await runner.runTests([ ]); |