import { describe, it, expect } from 'vitest'; import clock from '../../public/views/cards/clock.js'; import weather from '../../public/views/cards/weather.js'; import hostPerf from '../../public/views/cards/host_perf.js'; import jobs from '../../public/views/cards/jobs.js'; import inbox from '../../public/views/cards/inbox.js'; import search from '../../public/views/cards/search.js'; import speedtest from '../../public/views/cards/speedtest.js'; // Every data card must satisfy the uniform contract that sacred_valley.js relies // on: { id, title, size: s|m|l, mount(), start(), stop() }. Importing the modules // is safe in node — their browser globals (document/localStorage/fetch) are only // touched inside mount()/load(), which this test never calls. const cards = { clock, weather, hostPerf, jobs, inbox, search, speedtest }; describe('card contract', () => { for (const [name, c] of Object.entries(cards)) { it(`${name} implements the card contract`, () => { expect(typeof c.id).toBe('string'); expect(typeof c.title).toBe('string'); expect(['s', 'm', 'l']).toContain(c.size); expect(typeof c.mount).toBe('function'); expect(typeof c.start).toBe('function'); expect(typeof c.stop).toBe('function'); }); } it('all card ids are unique', () => { const ids = Object.values(cards).map(c => c.id); expect(new Set(ids).size).toBe(ids.length); }); });