|
| 1 | +import { describe, it, expect, beforeAll } from 'vitest'; |
| 2 | +import { ComponentRegistry } from '@object-ui/core'; |
| 3 | + |
| 4 | +// Import the component to ensure it's registered |
| 5 | +import '../data-table'; |
| 6 | + |
| 7 | +describe('Data Table Component', () => { |
| 8 | + it('should register data-table component', () => { |
| 9 | + expect(ComponentRegistry.has('data-table')).toBe(true); |
| 10 | + }); |
| 11 | + |
| 12 | + it('should have correct component metadata', () => { |
| 13 | + const config = ComponentRegistry.getConfig('data-table'); |
| 14 | + expect(config).toBeDefined(); |
| 15 | + expect(config?.label).toBe('Data Table'); |
| 16 | + expect(config?.inputs).toBeDefined(); |
| 17 | + expect(config?.defaultProps).toBeDefined(); |
| 18 | + }); |
| 19 | + |
| 20 | + it('should have required inputs defined', () => { |
| 21 | + const config = ComponentRegistry.getConfig('data-table'); |
| 22 | + const inputNames = config?.inputs?.map(input => input.name) || []; |
| 23 | + |
| 24 | + expect(inputNames).toContain('columns'); |
| 25 | + expect(inputNames).toContain('data'); |
| 26 | + expect(inputNames).toContain('pagination'); |
| 27 | + expect(inputNames).toContain('searchable'); |
| 28 | + expect(inputNames).toContain('selectable'); |
| 29 | + expect(inputNames).toContain('sortable'); |
| 30 | + expect(inputNames).toContain('exportable'); |
| 31 | + expect(inputNames).toContain('rowActions'); |
| 32 | + }); |
| 33 | + |
| 34 | + it('should have default props with sample data', () => { |
| 35 | + const config = ComponentRegistry.getConfig('data-table'); |
| 36 | + expect(config?.defaultProps).toBeDefined(); |
| 37 | + expect(config?.defaultProps?.columns).toBeDefined(); |
| 38 | + expect(Array.isArray(config?.defaultProps?.columns)).toBe(true); |
| 39 | + expect(config?.defaultProps?.data).toBeDefined(); |
| 40 | + expect(Array.isArray(config?.defaultProps?.data)).toBe(true); |
| 41 | + }); |
| 42 | + |
| 43 | + it('should have correct default feature flags', () => { |
| 44 | + const config = ComponentRegistry.getConfig('data-table'); |
| 45 | + expect(config?.defaultProps?.pagination).toBe(true); |
| 46 | + expect(config?.defaultProps?.searchable).toBe(true); |
| 47 | + expect(config?.defaultProps?.selectable).toBe(true); |
| 48 | + expect(config?.defaultProps?.sortable).toBe(true); |
| 49 | + expect(config?.defaultProps?.exportable).toBe(true); |
| 50 | + expect(config?.defaultProps?.rowActions).toBe(true); |
| 51 | + }); |
| 52 | +}); |
0 commit comments