同步:补齐已发布的查询面板与不良构成源码

This commit is contained in:
2026-11-01 22:49:56 +08:00
parent db5349dbde
commit 5bcf1dee4f
11 changed files with 390 additions and 108 deletions
@@ -0,0 +1,18 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { selectTrendPeriod } from '../src/trendPeriodSelection.ts';
const current={year:2026,month:9,quarter:3,period:'month'};
test('clicking the selected month returns to annual scope; another month selects that month',()=>{
assert.deepEqual(selectTrendPeriod('2026-09',current),{...current,period:'year'});
assert.deepEqual(selectTrendPeriod('2026-08',current),{...current,month:8});
assert.deepEqual(selectTrendPeriod('08月',current),{...current,month:8});
});
test('quarter selection and toggling preserve the selected year',()=>{
assert.deepEqual(selectTrendPeriod('2025-Q4',current),{...current,year:2025,quarter:4,period:'quarter'});
assert.deepEqual(selectTrendPeriod('2026-Q3',{...current,period:'quarter'}),{...current,period:'year'});
});
test('annual selection and invalid values cannot produce an invalid month',()=>{
assert.deepEqual(selectTrendPeriod('2025',current),{...current,year:2025,period:'year'});
assert.equal(selectTrendPeriod('2026-13',current),current);
assert.equal(selectTrendPeriod('invalid',current),current);
});