24 lines
1006 B
JavaScript
24 lines
1006 B
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { validateConfig } from '../src/config.js';
|
|
|
|
const valid = () => ({
|
|
theme: { primary: 'cyan', accent: 'yellow', muted: 'brightBlack' },
|
|
host: { port: 2222, notificationPort: 7777, hostKeyPath: 'data/host.key' },
|
|
adminPublicKeys: []
|
|
});
|
|
|
|
test('accepts a valid configuration', () => assert.equal(validateConfig(valid()).host.port, 2222));
|
|
test('rejects invalid ports with an actionable path', () => {
|
|
const config = valid(); config.host.port = 70000;
|
|
assert.throws(() => validateConfig(config), /host\.port/);
|
|
});
|
|
test('rejects unknown colors with an actionable path', () => {
|
|
const config = valid(); config.theme.primary = 'orange';
|
|
assert.throws(() => validateConfig(config), /theme\.primary/);
|
|
});
|
|
test('accepts key blobs and OpenSSH public-key lines', () => {
|
|
const config = valid(); config.adminPublicKeys = ['QUJDRA==', 'ssh-ed25519 QUJDRA== owner'];
|
|
assert.doesNotThrow(() => validateConfig(config));
|
|
});
|