Download client/src/components/ProjectHierarchyTable.test.tsx from zuocong12/README: direct link, hf CLI and curl.
- Browser
- Download file 4.41 kB
-
https://huggingface.co/spaces/zuocong12/README/resolve/main/client/src/components/ProjectHierarchyTable.test.tsx
- Command line
-
hf download hf://spaces/zuocong12/README/client/src/components/ProjectHierarchyTable.test.tsx
-
curl -L -o ProjectHierarchyTable.test.tsx https://huggingface.co/spaces/zuocong12/README/resolve/main/client/src/components/ProjectHierarchyTable.test.tsx
4.41 kB
| /** | |
| * Tests for ProjectHierarchyTable Current Node Rendering Logic | |
| */ | |
| import { describe, it, expect } from 'vitest'; | |
| /** | |
| * Simulate the renderCurrentNode logic for testing | |
| * This matches the exact implementation in ProjectHierarchyTable | |
| */ | |
| function renderCurrentNodeLogic(nodeValue: string): 'in-progress' | 'overdue' | 'completed' | 'default' { | |
| // Data cleaning: trim to remove invisible spaces | |
| const status = (nodeValue || '').toString().trim(); | |
| switch (status) { | |
| case '进行中': | |
| return 'in-progress'; | |
| case '已超时': | |
| return 'overdue'; | |
| case '已完成': | |
| return 'completed'; | |
| default: | |
| return 'default'; | |
| } | |
| } | |
| describe('ProjectHierarchyTable - Current Node Rendering', () => { | |
| describe('Critical Status Display', () => { | |
| it('should render "进行中" (In Progress) with yellow styling', () => { | |
| const result = renderCurrentNodeLogic('进行中'); | |
| expect(result).toBe('in-progress'); | |
| }); | |
| it('should render "已超时" (Overdue) with red styling', () => { | |
| const result = renderCurrentNodeLogic('已超时'); | |
| expect(result).toBe('overdue'); | |
| }); | |
| it('should render "已完成" (Completed) with green styling', () => { | |
| const result = renderCurrentNodeLogic('已完成'); | |
| expect(result).toBe('completed'); | |
| }); | |
| it('should handle text with leading/trailing whitespace', () => { | |
| expect(renderCurrentNodeLogic(' 进行中 ')).toBe('in-progress'); | |
| expect(renderCurrentNodeLogic(' 已超时 ')).toBe('overdue'); | |
| expect(renderCurrentNodeLogic('已完成 ')).toBe('completed'); | |
| }); | |
| }); | |
| describe('Non-Critical Status Display (Show All)', () => { | |
| it('should return default for "T1" status', () => { | |
| const result = renderCurrentNodeLogic('T1'); | |
| expect(result).toBe('default'); | |
| }); | |
| it('should return default for "PQR" status', () => { | |
| const result = renderCurrentNodeLogic('PQR'); | |
| expect(result).toBe('default'); | |
| }); | |
| it('should return default for "VMP" status', () => { | |
| const result = renderCurrentNodeLogic('VMP'); | |
| expect(result).toBe('default'); | |
| }); | |
| it('should return default for "MP" status', () => { | |
| const result = renderCurrentNodeLogic('MP'); | |
| expect(result).toBe('default'); | |
| }); | |
| it('should return default for "KICK OFF" status', () => { | |
| const result = renderCurrentNodeLogic('KICK OFF'); | |
| expect(result).toBe('default'); | |
| }); | |
| it('should return default for "G/L" status', () => { | |
| const result = renderCurrentNodeLogic('G/L'); | |
| expect(result).toBe('default'); | |
| }); | |
| it('should return default for "PB2" status', () => { | |
| const result = renderCurrentNodeLogic('PB2'); | |
| expect(result).toBe('default'); | |
| }); | |
| it('should return default for blank/empty string', () => { | |
| expect(renderCurrentNodeLogic('')).toBe('default'); | |
| expect(renderCurrentNodeLogic(' ')).toBe('default'); | |
| }); | |
| it('should return default for "-" placeholder', () => { | |
| const result = renderCurrentNodeLogic('-'); | |
| expect(result).toBe('default'); | |
| }); | |
| it('should return default for any other arbitrary text', () => { | |
| expect(renderCurrentNodeLogic('Random Text')).toBe('default'); | |
| expect(renderCurrentNodeLogic('测试')).toBe('default'); | |
| expect(renderCurrentNodeLogic('123')).toBe('default'); | |
| }); | |
| }); | |
| describe('Edge Cases', () => { | |
| it('should handle trailing spaces correctly (trim before match)', () => { | |
| // These SHOULD match after trimming | |
| expect(renderCurrentNodeLogic('进行中 ')).toBe('in-progress'); | |
| expect(renderCurrentNodeLogic(' 已超时')).toBe('overdue'); | |
| expect(renderCurrentNodeLogic(' 已完成 ')).toBe('completed'); | |
| }); | |
| it('should be case-sensitive (exact match required)', () => { | |
| // These should NOT match because they are not exact | |
| expect(renderCurrentNodeLogic('进行中。')).toBe('default'); // Extra punctuation | |
| expect(renderCurrentNodeLogic('已 超 时')).toBe('default'); // Extra spaces in middle | |
| expect(renderCurrentNodeLogic('COMPLETED')).toBe('default'); // English | |
| }); | |
| it('should handle undefined/null gracefully', () => { | |
| expect(renderCurrentNodeLogic(undefined as any)).toBe('default'); | |
| expect(renderCurrentNodeLogic(null as any)).toBe('default'); | |
| }); | |
| }); | |
| }); | |