Files
sunrise/tests/threads-config.test.ts

17 lines
802 B
TypeScript

import assert from 'node:assert/strict';
import { test } from 'node:test';
import { loadThreadsConfig } from '../server/threads/config.ts';
test('Threads JSON sample loads with relative paths and no embedded token', () => {
const config = loadThreadsConfig(new URL('../.env.threads.sample.json', import.meta.url));
assert.equal(config.accessToken, '');
assert.equal(config.siteUrl, 'https://sunrise.horoli.kr');
assert.equal(config.imageDir, 'dist/threads-captures');
});
test('missing configuration is permitted only for capture preview', () => {
const missing = new URL('../.tmp/threads-config-does-not-exist.json', import.meta.url);
assert.throws(() => loadThreadsConfig(missing), /copy .env.threads.sample.json/);
assert.equal(loadThreadsConfig(missing, true).accessToken, '');
});