integration layer; merge work on indicators from forks with existing ingestion pipeline
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import { MappingSet } from './mapping-set';
|
||||
|
||||
describe('MappingSet', () => {
|
||||
it('seeds from suggestions, skipping unmatched columns and keeping confidence', () => {
|
||||
const set = new MappingSet();
|
||||
set.seed([
|
||||
{ source_column: 'a', target_field: 'x', confidence: 0.8, reason: 'synonym' },
|
||||
{ source_column: 'b', target_field: null, confidence: 0, reason: 'none' },
|
||||
]);
|
||||
expect(set.items()).toEqual([{ source: 'a', field: 'x', confidence: 0.8, reason: 'synonym' }]);
|
||||
});
|
||||
|
||||
it('keeps the mapping 1:1 in both directions', () => {
|
||||
const set = new MappingSet();
|
||||
set.assign('a', 'x');
|
||||
set.assign('b', 'x'); // field x now fed by b
|
||||
set.assign('b', 'y'); // column b moves to y
|
||||
expect(set.toRecord()).toEqual({ b: 'y' });
|
||||
});
|
||||
|
||||
it('fillFrom never overrides a manual choice', () => {
|
||||
const set = new MappingSet();
|
||||
set.assign('manual', 'x');
|
||||
const added = set.fillFrom([
|
||||
{ source_column: 'auto', target_field: 'x', confidence: 0.9, reason: 'normalized' },
|
||||
{ source_column: 'other', target_field: 'y', confidence: 0.7, reason: 'fuzzy' },
|
||||
]);
|
||||
expect(added).toBe(1);
|
||||
expect(set.toRecord()).toEqual({ manual: 'x', other: 'y' });
|
||||
});
|
||||
|
||||
it('confirm drops the suggestion marker; release removes by field or by source', () => {
|
||||
const set = new MappingSet();
|
||||
set.seed([
|
||||
{ source_column: 'a', target_field: 'x', confidence: 0.8, reason: 'synonym' },
|
||||
{ source_column: 'b', target_field: 'y', confidence: 0.8, reason: 'synonym' },
|
||||
]);
|
||||
set.confirm('x');
|
||||
expect(set.byField().get('x')).toEqual({ source: 'a', field: 'x' });
|
||||
set.releaseField('x');
|
||||
set.releaseSource('b');
|
||||
expect(set.size()).toBe(0);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user