37 lines
1 KiB
JavaScript
37 lines
1 KiB
JavaScript
// The setup assistant's "is ruth missing" check. Run by `npm test`.
|
|
import assert from "node:assert/strict";
|
|
import { test } from "node:test";
|
|
import { ruthIsMissing } from "../src/shell/ruth-missing.ts";
|
|
|
|
const answering =
|
|
(body, ok = true) =>
|
|
async () => ({
|
|
ok,
|
|
json: async () => body,
|
|
});
|
|
|
|
test("a roster without ruth means ruth is missing", async () => {
|
|
assert.equal(
|
|
await ruthIsMissing(answering([{ name: "atlas" }, { name: "argus" }])),
|
|
true,
|
|
);
|
|
assert.equal(await ruthIsMissing(answering([])), true);
|
|
});
|
|
|
|
test("a roster with ruth means she is not missing", async () => {
|
|
assert.equal(
|
|
await ruthIsMissing(answering([{ name: "atlas" }, { name: "ruth" }])),
|
|
false,
|
|
);
|
|
});
|
|
|
|
test("anything but a clear answer is not missing", async () => {
|
|
assert.equal(await ruthIsMissing(answering([], false)), false);
|
|
assert.equal(await ruthIsMissing(answering({ not: "a list" })), false);
|
|
assert.equal(
|
|
await ruthIsMissing(async () => {
|
|
throw new Error("offline");
|
|
}),
|
|
false,
|
|
);
|
|
});
|