waterSupplyWorkOrderStatusDict.test.mjs 1.2 KB

1234567891011121314151617181920212223242526
  1. import assert from 'node:assert/strict'
  2. import { readFile } from 'node:fs/promises'
  3. import test from 'node:test'
  4. import { orderStatusType, orderStatusText } from '../src/views/subSystem/pipeNetwork/ops/workOrder/workOrderDict.js'
  5. test('shared work-order dictionary covers the authoritative 0-7 status codes', () => {
  6. assert.deepEqual(
  7. [0, 1, 2, 3, 4, 5, 6, 7].map(orderStatusText),
  8. ['待派单', '待接单', '已接单', '处理中', '待验收', '已结案', '延期中', '已取消']
  9. )
  10. const types = [0, 1, 2, 3, 4, 5, 6, 7].map(orderStatusType)
  11. assert.ok(types.every(type => ['danger', 'warning', 'primary', 'success', 'info'].includes(type)))
  12. assert.equal(orderStatusType(5), 'success')
  13. assert.equal(orderStatusType(7), 'info')
  14. })
  15. test('water supply device pages reuse the shared dictionary instead of a private status table', async () => {
  16. const source = await readFile('src/views/subSystem/waterSupply/components/WaterDevicePage.vue', 'utf8')
  17. assert.doesNotMatch(source, /function\s+workOrderStatusType/, '页面不应自带工单状态色表')
  18. assert.match(
  19. source,
  20. /from '@\/views\/subSystem\/pipeNetwork\/ops\/workOrder\/workOrderDict\.js'/u,
  21. '页面应复用统一工单字典'
  22. )
  23. })