import { describe, it, expect } from 'vitest'; import { CATALOGUES, getCatalogue, getCatalogueItem, itemLabels } from '../src/model/catalog'; describe('catalogues', () => { it('ships the built-in catalogues', () => { expect(CATALOGUES.map((c) => c.id)).toEqual( expect.arrayContaining(['pipeDiameters', 'materials', 'media', 'insulation']), ); }); it('looks up catalogues and items by id', () => { expect(getCatalogue('materials')?.label).toMatch(/material/i); expect(getCatalogueItem('pipeDiameters', 'dn50')?.attrs?.innerDiameter).toBe(50); expect(getCatalogueItem('pipeDiameters', 'dn999')).toBeUndefined(); expect(getCatalogueItem('nope', 'dn50')).toBeUndefined(); expect(getCatalogueItem('materials', null)).toBeUndefined(); }); it('resolves labels for multi-item values, skipping unknown ids', () => { expect(itemLabels('insulation', ['none', 'pur', 'ghost'])).toEqual(['None', 'PUR shell 40mm']); expect(itemLabels('ghost-cat', ['x'])).toEqual([]); }); });