test(metadata): drill into components array for BMP280 lookup

components-metadata.json is shaped { version, components: [...] }, not a
flat array. The previous test assumed the latter and crashed on
default.find at module load on master, breaking CI for every PR.
This commit is contained in:
davidmonterocrespo24 2026-05-09 23:52:36 +02:00
parent a7e796161e
commit 1869ace89d
1 changed files with 10 additions and 3 deletions

View File

@ -1,11 +1,18 @@
import { describe, it, expect } from 'vitest';
import metadata from '../../public/components-metadata.json';
interface ComponentMetadataEntry {
id: string;
tagName: string;
category: string;
pinCount: number;
[key: string]: unknown;
}
describe('component metadata — BMP280 entry', () => {
it('is registered with id "bmp280" and tagName "velxio-bmp280"', () => {
const entry = (metadata as Array<Record<string, unknown>>).find(
(c) => c.id === 'bmp280',
);
const components = (metadata as { components: ComponentMetadataEntry[] }).components;
const entry = components.find((c) => c.id === 'bmp280');
expect(entry, 'BMP280 missing from components-metadata.json').toBeDefined();
expect(entry!.tagName).toBe('velxio-bmp280');
expect(entry!.category).toBe('sensor');