import { validateCog } from './is-cog.validator' ; describe ( 'validateCog' , ( ) => { describe ( 'should return "false", if the argument is not a valid cog because of' , ( ) => { it ( 'is not a string' , ( ) => { const notAstring = 42 ; const valid = validateCog ( notAstring ) ; expect ( valid ) . toStrictEqual ( false ) ; } ) ; it ( 'is an empty string' , ( ) => { const notAstring = '' ; const valid = validateCog ( notAstring ) ; expect ( valid ) . toStrictEqual ( false ) ; } ) ; it ( 'is not a valid cog, length < 3' , ( ) => { const cog = 'nop' ; const valid = validateCog ( cog ) ; expect ( valid ) . toStrictEqual ( false ) ; } ) ; it ( 'last 3 chars are not numbers' , ( ) => { const cog = '13p12' ; const valid = validateCog ( cog ) ; expect ( valid ) . toStrictEqual ( false ) ; } ) ; it ( 'length === 5 but first char is not number' , ( ) => { const cog = 'nop12' ; const valid = validateCog ( cog ) ; expect ( valid ) . toStrictEqual ( false ) ; } ) ; it ( 'length === 5 but second char is not A or B' , ( ) => { const cog = '1C712' ; const valid = validateCog ( cog ) ; expect ( valid ) . toStrictEqual ( false ) ; } ) ; } ) ; describe ( 'return "true", if the argument is a valid cog' , ( ) => { it ( 'all numbers' , ( ) => { const cog = '95277' ; const valid = validateCog ( cog ) ; expect ( valid ) . toStrictEqual ( true ) ; } ) ; it ( 'is a valid cog (CORSE 2Axxx)' , ( ) => { const cog = '2A123' ; const valid = validateCog ( cog ) ; expect ( valid ) . toStrictEqual ( true ) ; } ) ; it ( 'is a valid cog (CORSE 2Bxxx)' , ( ) => { const cog = '2B123' ; const valid = validateCog ( cog ) ; expect ( valid ) . toStrictEqual ( true ) ; } ) ; } ) ; } ) ;