import { 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'); }); });