gongxiangp2/components/department-dashboard/business-trends.test.ts
2026-08-19 12:08:38 +08:00

37 lines
1.2 KiB
TypeScript

import {
BUSINESS_TREND_BRANDS,
BUSINESS_TREND_STAGES,
BUSINESS_TREND_WEEK_LABELS,
summarizeBusinessTrend,
} from './business-trends'
describe('business trends configuration', () => {
it('contains six brands, eight weeks and the confirmed five project stages', () => {
expect(BUSINESS_TREND_BRANDS).toHaveLength(6)
expect(new Set(BUSINESS_TREND_BRANDS.map((brand) => brand.key)).size).toBe(6)
expect(BUSINESS_TREND_BRANDS.filter((brand) => brand.team === '创意A')).toHaveLength(3)
expect(BUSINESS_TREND_BRANDS.filter((brand) => brand.team === '创意B')).toHaveLength(3)
expect(BUSINESS_TREND_WEEK_LABELS).toHaveLength(8)
expect(BUSINESS_TREND_STAGES.map((stage) => stage.label)).toEqual([
'Brief',
'设计',
'拍摄',
'后期',
'待上线',
])
for (const brand of BUSINESS_TREND_BRANDS) {
expect(brand.planned).toHaveLength(8)
expect(brand.actual).toHaveLength(8)
}
})
it('calculates attainment from actual completed total divided by planned total', () => {
expect(summarizeBusinessTrend(BUSINESS_TREND_BRANDS[0])).toEqual({
plannedTotal: 44,
actualTotal: 40,
attainmentRate: 90.9,
})
})
})