Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
import { describe, it, expect } from 'vitest';
import { readFile } from 'node:fs/promises';
import path from 'node:path';
import { normalizeReport } from '../src/kicad/report.js';
import { REPORTS } from './helpers.js';
const load = async (name: string): Promise<unknown> =>
JSON.parse(await readFile(path.join(REPORTS, name), 'utf8'));
describe('report normalizer', () => {
it('normalizes a clean ERC report', async () => {
const r = normalizeReport(await load('erc-clean.json'), 'erc');
expect(r.ok).toBe(true);
expect(r.violations).toEqual([]);
});
it('normalizes a clean DRC report', async () => {
const r = normalizeReport(await load('drc-clean.json'), 'drc');
expect(r.ok).toBe(true);
});
it('carries type, severity, and location for violations (AC-2.2 source)', async () => {
const r = normalizeReport(await load('erc-unconnected-pin.json'), 'erc');
expect(r.ok).toBe(false);
const pin = r.violations.find((v) => v.type === 'pin_not_connected');
expect(pin).toBeDefined();
expect(pin!.severity).toBe('error');
expect(pin!.sheet).toBe('/');
expect(pin!.items[0]!.x).toBeTypeOf('number');
});
it('tolerates unknown shapes', () => {
expect(normalizeReport({}, 'erc').ok).toBe(true);
expect(normalizeReport({ violations: [{}] }, 'drc').violations).toHaveLength(1);
});
});
696b6f9f0This file is pinned to the selected release. Download the original to open it in your design tool.