Share card-number normalization across reconcile and identify paths, retry set/name matches when OCR uses leading-zero collector numbers, and extend in-flight locks to all scanner destination actions with disabled Mark Owned feedback. Co-authored-by: Cursor <cursoragent@cursor.com>
35 lines
1,017 B
JavaScript
35 lines
1,017 B
JavaScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import {
|
|
cardNumbersEquivalent,
|
|
findPrintingByCollectorNumber,
|
|
normalizeCardNumber,
|
|
} from '../../lib/card-number-utils.js';
|
|
|
|
describe('normalizeCardNumber', () => {
|
|
it('treats leading-zero numerators as equivalent', () => {
|
|
expect(normalizeCardNumber('015/208')).toBe('15/208');
|
|
expect(normalizeCardNumber('15/208')).toBe('15/208');
|
|
expect(normalizeCardNumber('18/88')).toBe('18/88');
|
|
});
|
|
});
|
|
|
|
describe('cardNumbersEquivalent', () => {
|
|
it('matches normalized collector numbers', () => {
|
|
expect(cardNumbersEquivalent('015/208', '15/208')).toBe(true);
|
|
expect(cardNumbersEquivalent('18/88', '015/208')).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('findPrintingByCollectorNumber', () => {
|
|
it('returns the sole matching printing', () => {
|
|
const match = findPrintingByCollectorNumber(
|
|
[
|
|
{ id: 1, card_number: '18/88' },
|
|
{ id: 2, card_number: '19/88' },
|
|
],
|
|
'018/88'
|
|
);
|
|
expect(match?.id).toBe(1);
|
|
});
|
|
});
|