Files
RedditBot/tests/dashboard-assets.test.ts

25 lines
898 B
TypeScript

import path from 'node:path';
import { describe, expect, it, vi } from 'vitest';
import { resolveDashboardAssets } from '../src/web/dashboard-assets.js';
describe('resolveDashboardAssets', () => {
it('selects the built React dashboard when its index exists', () => {
const workspace = path.resolve('workspace');
const reactIndex = path.join(workspace, 'apps', 'dashboard', 'dist', 'index.html');
const fileExists = vi.fn((candidate: string) => candidate === reactIndex);
expect(resolveDashboardAssets(workspace, fileExists)).toEqual({
directory: path.dirname(reactIndex),
indexFile: reactIndex,
});
});
it('fails clearly when the production React build is missing', () => {
const workspace = path.resolve('workspace');
expect(() => resolveDashboardAssets(workspace, () => false)).toThrow(
'React dashboard build is missing',
);
});
});