27 lines
848 B
JavaScript
27 lines
848 B
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { loadConfig } from "../src/config.js";
|
|
|
|
test("loads defaults", () => {
|
|
const config = loadConfig({});
|
|
assert.equal(config.port, 3000);
|
|
assert.equal(config.suwayomi.graphqlUrl, "http://suwayomi:4567/api/graphql");
|
|
assert.equal(config.feed.itemLimit, 50);
|
|
});
|
|
|
|
test("requires credentials for authenticated modes", () => {
|
|
assert.throws(
|
|
() => loadConfig({ SUWAYOMI_AUTH_MODE: "ui_login" }),
|
|
/USERNAME and SUWAYOMI_PASSWORD/,
|
|
);
|
|
assert.throws(
|
|
() => loadConfig({ RSS_USERNAME: "reader" }),
|
|
/must be set together/,
|
|
);
|
|
});
|
|
|
|
test("validates bounded integer settings", () => {
|
|
assert.throws(() => loadConfig({ FEED_ITEM_LIMIT: "201" }), /between 1 and 200/);
|
|
assert.throws(() => loadConfig({ PORT: "wat" }), /PORT must be an integer/);
|
|
});
|