Assessor_2.0/tests/analysis/identifiers.test.ts

13 lines
721 B
TypeScript

import { describe, expect, it } from 'vitest';
import { stableRecordId } from '../../src/shared/identifiers';
describe('stableRecordId', () => {
it('is stable across row positions and changes when source content changes', () => {
const base = { sourceFile: 'synthetic.xlsx', sheetName: 'Indicator Results', headers: ['Name', 'Severity'], row: ['A', 'High'] };
expect(stableRecordId(base)).toBe(stableRecordId({ ...base }));
expect(stableRecordId(base)).not.toBe(stableRecordId({ ...base, row: ['A', 'Low'] }));
expect(stableRecordId(base)).not.toBe(stableRecordId({ ...base, sourceFile: 'other.xlsx' }));
expect(stableRecordId(base)).not.toBe(stableRecordId({ ...base, occurrence: 1 }));
});
});