import enumRender from '../enum-render'; describe('enumRender', () => { it('should return the label when value is a plain object', () => { const value = { label: 'Option 1', value: 'option1' }; const dataSource = [ { label: 'Option 1', value: 'option1' }, { label: 'Option 2', value: 'option2' }, ]; expect(enumRender(value, dataSource)).toBe('Option 1'); }); it('should return the label when value is a string', () => { const value = 'option2'; const dataSource = [ { label: 'Option 1', value: 'option1' }, { label: 'Option 2', value: 'option2' }, ]; expect(enumRender(value, dataSource)).toBe('Option 2'); }); it('should return the label when value is not found in the dataSource', () => { const value = 'option3'; const dataSource = [ { label: 'Option 1', value: 'option1' }, { label: 'Option 2', value: 'option2' }, ]; expect(enumRender(value, dataSource)).toBe('option3'); }); it('should return the label when dataSource is empty', () => { const value = 'option1'; const dataSource = []; expect(enumRender(value, dataSource)).toBe('option1'); }); it('should return the label when dataSource is undefined', () => { const value = 'option1'; const dataSource = undefined; expect(enumRender(value, dataSource)).toBe('option1'); }); });