| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import test from 'node:test'
- import assert from 'node:assert/strict'
- import { readFile } from 'node:fs/promises'
- import { getMonitoringPointColor, getMonitoringPointLabel, getMonitoringPointStatus, getMonitoringPointTagType } from '../src/utils/gisMapColors.js'
- test('shared gis map canvas converts WGS84 coordinates before BMapGL rendering', async () => {
- const source = await readFile('src/components/GisMapCanvas.vue', 'utf8')
- assert.match(source, /import \{ convertCoord \} from '@\/utils\/coordTransform'/u)
- assert.match(source, /const \[lng, lat\] = convertCoord\(point\.lng, point\.lat\)/u)
- assert.match(source, /new BMapGL\.Point\(lng, lat\)/u)
- assert.match(source, /mapInstance\.setViewport\(bmapPoints/u)
- assert.doesNotMatch(source, /new BMapGL\.Point\(point\.lng, point\.lat\)/u)
- })
- test('shared gis map canvas uses the common point marker contract', async () => {
- const source = await readFile('src/components/GisMapCanvas.vue', 'utf8')
- assert.match(source, /markerSize: \{ type: Number, default: 22 \}/u)
- assert.match(source, /border-radius:50%/u)
- assert.match(source, /border:3px solid #fff/u)
- assert.match(source, /class="marker-text"/u)
- assert.match(source, /emit\('point-click', point\)/u)
- })
- test('monitoring point colors follow the documented status semantics', () => {
- assert.equal(getMonitoringPointStatus({ relatedOrderNo: 'WO-1' }), 'workOrder')
- assert.equal(getMonitoringPointStatus({ relatedWorkOrderNo: 'WO-2' }), 'workOrder')
- assert.equal(getMonitoringPointStatus({ alarmStatus: 1 }), 'alarm')
- assert.equal(getMonitoringPointStatus({ currentStatus: 3 }), 'warning')
- assert.equal(getMonitoringPointStatus({ onlineStatus: 0 }), 'offline')
- assert.equal(getMonitoringPointStatus({}), 'normal')
- assert.equal(getMonitoringPointColor({ relatedOrderNo: 'WO-1' }), '#3498db')
- assert.equal(getMonitoringPointColor({ alarmStatus: 1 }), '#e74c3c')
- assert.equal(getMonitoringPointColor({ currentStatus: 3 }), '#f1c40f')
- assert.equal(getMonitoringPointColor({ onlineStatus: 0 }), '#95a5a6')
- assert.equal(getMonitoringPointColor({}), '#2ecc71')
- assert.equal(getMonitoringPointLabel({ currentStatus: 3 }), '预警')
- assert.equal(getMonitoringPointLabel({ relatedWorkOrderNo: 'WO-2' }), '关联工单')
- assert.equal(getMonitoringPointTagType({ relatedWorkOrderNo: 'WO-2' }), 'primary')
- assert.equal(getMonitoringPointTagType({ onlineStatus: 0 }), 'info')
- })
- test('water supply GIS pages share the common canvas component', async () => {
- const deviceSource = await readFile('src/views/subSystem/waterSupply/components/WaterDeviceGisMap.vue', 'utf8')
- const facilitySource = await readFile('src/views/subSystem/waterSupply/facility/gis.vue', 'utf8')
- assert.match(deviceSource, /<GisMapCanvas/u)
- assert.match(deviceSource, /value="workOrder">关联工单/u)
- assert.match(deviceSource, /legend-dot warning/u)
- assert.match(deviceSource, /getMonitoringPointTagType/u)
- assert.match(deviceSource, /:points="mapPoints"/u)
- assert.match(deviceSource, /@point-click="openDetail\(\$event\.equipmentId\)"/u)
- assert.match(facilitySource, /<GisMapCanvas/u)
- assert.match(facilitySource, /:points="mapPoints"/u)
- assert.match(facilitySource, /:lines="mapLines"/u)
- assert.match(facilitySource, /@point-click="openFacilityDetail"/u)
- const alarmSource = await readFile('src/views/subSystem/waterSupply/components/WaterAlarmPage.vue', 'utf8')
- assert.match(alarmSource, /<GisMapCanvas/u)
- assert.match(alarmSource, /getMonitoringPointColor\(point\)/u)
- assert.match(alarmSource, /一级报警/u)
- assert.doesNotMatch(alarmSource, /color: point\.relatedOrderNo \?/u)
- assert.match(alarmSource, /:points="gisMapPoints"/u)
- assert.match(alarmSource, /@point-click="openDetail"/u)
- })
|