import test from 'unit.js' ; import { isEnum , Enum } from '../index' ; const values = [ 'one' , 'two' , 'three' ] ; const numbers = Enum ( ... values ) ; describe ( 'Tests Enums' , ( ) => { it ( 'Verifies valid enum values' , done => { test . value ( values . reduce ( ( isValid , value ) => isValid && isEnum ( numbers , value ) , true ) ) . is ( true ) ; test . value ( Object . keys ( numbers ) . reduce ( ( isValid , value ) => isValid && isEnum ( numbers , value ) , true ) ) . is ( true ) ; done ( ) ; } ) ; it ( 'Verifies missing enum value' , done => { test . value ( isEnum ( numbers , 'four' ) ) . is ( false ) ; done ( ) ; } ) ; it ( 'Verifies invalid numeric enum value' , done => { test . value ( isEnum ( numbers , 4 ) ) . is ( false ) ; done ( ) ; } ) ; it ( 'Verifies invalid null enum value' , done => { test . value ( isEnum ( numbers , null ) ) . is ( false ) ; done ( ) ; } ) ; it ( 'Verifies invalid undefined enum value' , done => { test . value ( isEnum ( numbers , undefined ) ) . is ( false ) ; done ( ) ; } ) ; it ( 'Verifies invalid object enum value' , done => { test . value ( isEnum ( numbers , { one : 'one' } ) ) . is ( false ) ; done ( ) ; } ) ; } ) ;