import { Enum } from '../Enum' ; enum NumericEnum { Apple = 1 , Banana } enum StringEnum { Apple = 'apple' , Banana = 'banana' } enum MixedEnum { Apple = 1 , Banana = 'banana' } describe ( 'Enum' , ( ) => { test ( 'tryGetValueByKey' , ( ) => { const numeric1 = Enum . tryGetValueByKey ( NumericEnum , 'Apple' ) ; expect ( numeric1 ) . toBe ( NumericEnum . Apple ) ; const numeric2 = Enum . tryGetValueByKey ( NumericEnum , 'Coconut' ) ; expect ( numeric2 ) . toBeUndefined ( ) ; const string1 = Enum . tryGetValueByKey ( StringEnum , 'Apple' ) ; expect ( string1 ) . toBe ( StringEnum . Apple ) ; const string2 = Enum . tryGetValueByKey ( StringEnum , 'Coconut' ) ; expect ( string2 ) . toBeUndefined ( ) ; const mixed1 = Enum . tryGetValueByKey ( MixedEnum , 'Apple' ) ; expect ( mixed1 ) . toBe ( MixedEnum . Apple ) ; const mixed2 = Enum . tryGetValueByKey ( MixedEnum , 'Banana' ) ; expect ( mixed2 ) . toBe ( MixedEnum . Banana ) ; const mixed3 = Enum . tryGetValueByKey ( MixedEnum , 'Coconut' ) ; expect ( mixed3 ) . toBeUndefined ( ) ; } ) ; test ( 'tryGetKeyByNumber' , ( ) => { const numeric1 = Enum . tryGetKeyByNumber ( NumericEnum , NumericEnum . Apple as number ) ; expect ( numeric1 ) . toBe ( 'Apple' ) ; const numeric2 = Enum . tryGetKeyByNumber ( NumericEnum , - 1 ) ; expect ( numeric2 ) . toBeUndefined ( ) ; const string2 = Enum . tryGetKeyByNumber ( StringEnum , - 1 ) ; expect ( string2 ) . toBeUndefined ( ) ; const mixed1 = Enum . tryGetKeyByNumber ( MixedEnum , MixedEnum . Apple ) ; expect ( mixed1 ) . toBe ( 'Apple' ) ; const mixed3 = Enum . tryGetKeyByNumber ( MixedEnum , - 1 ) ; expect ( mixed3 ) . toBeUndefined ( ) ; } ) ; } ) ;