File size: 591 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import valueToEnum from '../value-to-enum';
enum TestEnum {
Value1 = 'Lions',
Value2 = 'Tigers',
Value3 = 'Bears',
Value4 = 'George Takei',
}
describe( 'valueToEnum', () => {
it( 'returns the appropriate enum value if one is found', () => {
const result = valueToEnum( TestEnum, 'Tigers', TestEnum.Value4 );
expect( result ).toBe( TestEnum.Value2 );
} );
it( 'returns the supplied fallback value if an enum value is not found', () => {
const result = valueToEnum( TestEnum, 'The Spanish Inquisition', TestEnum.Value4 );
expect( result ).toBe( TestEnum.Value4 );
} );
} );
|