优化
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { turnoverChart, turnoverNumber, windowText } from './turnoverPresentation'
|
||||
import type { TurnoverCharts, TurnoverWindowMetric } from './turnoverTypes'
|
||||
describe('turnover honest precision and charts', () => {
|
||||
it('keeps tiny positive values distinct from zero and unknown', () => {
|
||||
expect(turnoverNumber(0.000001)).toBe('<0.01')
|
||||
expect(turnoverNumber(0.01, 1)).toBe('<0.1')
|
||||
expect(turnoverNumber(0)).toBe('0'); expect(turnoverNumber(null)).toBe('—')
|
||||
})
|
||||
it('does not draw partial-window totals as daily averages or zero bars', () => {
|
||||
const partial: TurnoverWindowMetric = { days: 15, startDate: '2026-09-28', endDateExclusive: '2026-10-13', dataStatus: 'PARTIAL', observedQuantity: 150, outboundQuantity: null, averageDailyOutboundQuantity: null, completeDayCount: 7, partialDayCount: 1, unknownDayCount: 7, reasonCodes: [] }
|
||||
const charts: TurnoverCharts = { ownerPhysicalTop: [], unknownOwnerCount: 0, averageDaily: [{ ...partial, days: 7, dataStatus: 'COMPLETE', averageDailyOutboundQuantity: 10 }, partial] }
|
||||
const option = turnoverChart(charts, 'daily')
|
||||
expect(JSON.stringify(option.series)).toContain('"data":[10,null]')
|
||||
expect(windowText(partial)).toBe('已采集 150,覆盖不足')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user