feat(web): Vitest 测试基建与首批单测(#27)+ 公共格式化函数
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { aiClassLabel, riskLevelLabel } from './format';
|
||||
|
||||
describe('aiClassLabel', () => {
|
||||
it('映射 healthy/sick 为中文', () => {
|
||||
expect(aiClassLabel('healthy')).toBe('健康');
|
||||
expect(aiClassLabel('sick')).toBe('疑似异常');
|
||||
});
|
||||
it('未知类别原样返回', () => {
|
||||
expect(aiClassLabel('unknown')).toBe('unknown');
|
||||
});
|
||||
});
|
||||
|
||||
describe('riskLevelLabel', () => {
|
||||
it('映射四级风险', () => {
|
||||
expect(riskLevelLabel('green')).toBe('绿');
|
||||
expect(riskLevelLabel('yellow')).toBe('黄');
|
||||
expect(riskLevelLabel('orange')).toBe('橙');
|
||||
expect(riskLevelLabel('red')).toBe('红');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user