import { expect, test } from 'vitest';
import { mergeVehicleCandidates } from './vehicleCandidates';

test('deduplicates candidates by normalized VIN and merges protocol evidence', () => {
  const result = mergeVehicleCandidates([
    { vin: ' ltest000000000001 ', plate: '', protocol: 'JT808' },
    { vin: 'LTEST000000000001', plate: '粤A12345', protocol: 'GB32960' },
    { vin: 'LTEST000000000001', plate: '粤A12345', protocols: ['JT808', 'YUTONG_MQTT'] },
    { vin: '', plate: '无效记录', protocol: 'JT808' }
  ]);

  expect(result).toEqual([{
    vin: 'LTEST000000000001',
    plate: '粤A12345',
    protocol: 'JT808',
    protocols: ['JT808', 'GB32960', 'YUTONG_MQTT']
  }]);
});
