import { numberParser , ParsedNumber } from './numberParser' ; describe ( "parser" , ( ) => { it ( 'parses decimal number' , ( ) => { const result = numberParser . parse ( '10' ) ; expect ( result ) . not . toBeNull ( ) ; var number = result as ParsedNumber ; expect ( number . value ) . toBe ( 10 ) ; expect ( number . base ) . toBe ( 'dec' ) ; expect ( number . input ) . toBe ( '10' ) ; } ) ; it ( 'parses hex number' , ( ) => { const result = numberParser . parse ( '0xab' ) ; expect ( result ) . not . toBeNull ( ) ; var number = result as ParsedNumber ; expect ( number . value ) . toBe ( 171 ) ; expect ( number . base ) . toBe ( 'hex' ) ; expect ( number . input ) . toBe ( '0xab' ) ; } ) ; it ( 'parses bin number' , ( ) => { var result = numberParser . parse ( '0b0110' ) ; expect ( result ) . not . toBeNull ( ) ; var number = result as ParsedNumber ; expect ( number . value ) . toBe ( 6 ) ; expect ( number . base ) . toBe ( 'bin' ) ; expect ( number . input ) . toBe ( '0b0110' ) ; } ) ; it ( 'returns null on bad inputs' , ( ) => { expect ( numberParser . parse ( 'abc' ) ) . toBeNull ( ) ; expect ( numberParser . parse ( '' ) ) . toBeNull ( ) ; } ) ; } ) ;