Something went wrong. Try again.
A free, open-source, self-hosted place to write a novel.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536import { describe, expect, it, vi } from 'vitest';
const state = vi.hoisted(() => ({ page: { data: {} as { instance?: { name?: string } } }}));
vi.mock('$app/state', () => ({ page: state.page }));
const { instanceName } = await import('./instance-name.ts');
describe('instanceName', () => { it('uses the name the admin set', () => { state.page.data = { instance: { name: 'Ravenshold' } };
expect(instanceName()).toBe('Ravenshold'); });
it('trims the name before showing it', () => { state.page.data = { instance: { name: ' Ravenshold ' } };
expect(instanceName()).toBe('Ravenshold'); });
it('falls back to the product name when the layout has no instance', () => { state.page.data = {};
expect(instanceName()).toBe('Fablewright'); });
it('falls back when the name is empty or only spaces', () => { state.page.data = { instance: { name: ' ' } };
expect(instanceName()).toBe('Fablewright'); });});