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('实时参数字段映射契约通过')
|