yeg
2026-09-28 864ee2a6c3d86c6bb3af7eaf31b2390d2970c56e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
 
const view = await readFile(new URL('../src/views/TestConsole.vue', import.meta.url), 'utf8')
const liveService = await readFile(new URL('../../BatteryDetection/battery-business/src/main/java/com/battery/business/service/impl/TTestLiveServiceImpl.java', import.meta.url), 'utf8')
 
assert.match(view, /metric\(\['VOLTAGE', 'voltage'\], cabinetSource, 'voltageV'\)/)
assert.match(view, /metric\(\['CURRENT', 'current'\], cabinetSource, 'currentA'\)/)
assert.match(view, /metric\(\['CAPACITY', 'capacity'\], cabinetSource, 'capacityAh'\)/)
assert.match(view, /'positive_potential'/)
assert.match(view, /'negative_potential'/)
assert.match(view, /if \(receptionState\.value !== '接收中'\) return undefined/)
assert.match(view, /const collectorColumns = computed<CollectorColumn\[\]>\(\(\) =>/)
assert.match(view, /battery\.collectorChannels \|\| \[\]/)
assert.match(view, /v-for="column in collectorColumns"/)
assert.match(view, /item\.measurements\[column\.measurementCode\] \|\| '-'/)
assert.match(view, /if \(receptionState\.value === '接收中'\)/)
assert.match(liveService, /value\.put\("voltageV", channel\.latestSnapshot\(\)\.voltageV\(\)\)/)
assert.match(liveService, /value\.put\("currentA", channel\.latestSnapshot\(\)\.currentA\(\)\)/)
assert.match(liveService, /value\.put\("capacityAh", channel\.latestSnapshot\(\)\.capacityAh\(\)\)/)
assert.match(liveService, /if \(!receiving\)\s*return withoutSnapshot\(fresh\)/)
assert.doesNotMatch(liveService, /return freeze \? lastSources\.getOrDefault\(key, withoutSnapshot\(fresh\)\) : withoutSnapshot\(fresh\)/)
 
console.log('实时参数字段映射契约通过')