44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { describe, expect, test } from 'vitest';
|
|
import { summarizeVehicleService } from './vehicleService';
|
|
|
|
describe('summarizeVehicleService', () => {
|
|
test('marks unresolved vehicles as unavailable', () => {
|
|
expect(summarizeVehicleService({ resolved: false, sourceCount: 1, onlineSourceCount: 1 })).toMatchObject({
|
|
status: '不可服务',
|
|
risk: '身份未归并到 VIN'
|
|
});
|
|
});
|
|
|
|
test('prioritizes quality issues before missing source warnings', () => {
|
|
expect(summarizeVehicleService({
|
|
resolved: true,
|
|
sourceCount: 3,
|
|
onlineSourceCount: 2,
|
|
qualityIssueCount: 3,
|
|
missingProtocols: ['YUTONG_MQTT']
|
|
})).toMatchObject({
|
|
status: '降级可服务',
|
|
risk: '3 项质量问题影响可信度'
|
|
});
|
|
});
|
|
|
|
test('detects missing protocol evidence', () => {
|
|
expect(summarizeVehicleService({
|
|
resolved: true,
|
|
sourceCount: 2,
|
|
onlineSourceCount: 2,
|
|
missingProtocols: ['JT808', 'YUTONG_MQTT']
|
|
})).toMatchObject({
|
|
status: '降级可服务',
|
|
risk: '缺少 JT808、YUTONG_MQTT 来源'
|
|
});
|
|
});
|
|
|
|
test('marks complete online evidence as serviceable', () => {
|
|
expect(summarizeVehicleService({ resolved: true, sourceCount: 3, onlineSourceCount: 3 })).toMatchObject({
|
|
status: '可服务',
|
|
color: 'green'
|
|
});
|
|
});
|
|
});
|