1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
| import { describe, expect, it } from 'vitest';
|
| import { filterTrendOptions, filterTrendTableOptions, getTrendOptionSummary, normalizeTrendOptionValue } from '../trendOptionPopup';
|
| const options = [
| { label: '纯化水', value: 'pw' },
| { label: '注射用水', value: 'wfi' },
| { label: 'W-1', value: 'point-1' },
| ];
|
| describe('trend option popup helpers', () => {
| it('filters local options by label or value', () => {
| expect(filterTrendOptions(options, '注射')).toEqual([{ label: '注射用水', value: 'wfi' }]);
| expect(filterTrendOptions(options, 'POINT-1')).toEqual([{ label: 'W-1', value: 'point-1' }]);
| });
|
| it('builds a comma-separated summary in selected order', () => {
| expect(getTrendOptionSummary(['point-1', 'pw'], options)).toBe('W-1, 纯化水');
| });
|
| it('normalizes single and multiple values into draft keys', () => {
| expect(normalizeTrendOptionValue('pw')).toEqual(['pw']);
| expect(normalizeTrendOptionValue(['pw', 'wfi'])).toEqual(['pw', 'wfi']);
| expect(normalizeTrendOptionValue(undefined)).toEqual([]);
| });
|
| it('filters table options by every displayed column', () => {
| const rows = [
| { code: 'W-1', label: 'W-1', location: '制水间使用点', value: 'point-1' },
| { code: 'W-2', label: 'W-2', location: '灌装间回水口', value: 'point-2' },
| ];
|
| expect(filterTrendTableOptions(rows, '制水间', ['code', 'location'])).toEqual([rows[0]]);
| expect(filterTrendTableOptions(rows, 'W-2', ['code', 'location'])).toEqual([rows[1]]);
| });
| });
|
|