import { CaseInsensitiveObject , DefaultMultiValueObject , remapKeys , toHeaderCase , } from './utils' ; test ( 'toHeaderCase converts strings' , ( ) => { let allLower = 'abc' ; let allUpper = 'ABC' ; let lowerDash = 'ab-c' ; let mixed = 'x-ConTeNT-Type' ; allLower = toHeaderCase ( allLower ) ; allUpper = toHeaderCase ( allUpper ) ; lowerDash = toHeaderCase ( lowerDash ) ; mixed = toHeaderCase ( mixed ) ; expect ( allLower ) . toEqual ( 'Abc' ) ; expect ( allUpper ) . toEqual ( 'Abc' ) ; expect ( lowerDash ) . toEqual ( 'Ab-C' ) ; expect ( mixed ) . toEqual ( 'X-Content-Type' ) ; } ) ; test ( 'remapKeys changes key strings' , ( ) => { let single = { a : 'b' } ; let singleNumber = { a : 1 } ; let multi = { a : 'b' , b : 'c' } ; let multiMixed = { a : 1 , b : 'c' } ; single = remapKeys ( single , ( key ) => key + '1' ) ; singleNumber = remapKeys ( singleNumber , ( key ) => key + '1' ) ; multi = remapKeys ( multi , ( key ) => key + '1' ) ; multiMixed = remapKeys ( multiMixed , ( key ) => key + '1' ) ; expect ( single ) . toEqual ( { a1 : 'b' } ) ; expect ( singleNumber ) . toEqual ( { a1 : 1 } ) ; expect ( multi ) . toEqual ( { a1 : 'b' , b1 : 'c' } ) ; expect ( multiMixed ) . toEqual ( { a1 : 1 , b1 : 'c' } ) ; } ) ; test ( 'CaseInsensitiveObject set should set a lower-cased value' , ( ) => { const sut = new CaseInsensitiveObject ( ) ; sut [ 'A' ] = 'A' ; sut [ 'Bb' ] = 'Bb' ; sut [ 'c-C' ] = 'cc' ; sut [ 'd' ] = 'd' ; sut . E = 'e' ; sut . f = 'ff' ; expect ( sut ) . toEqual ( { a : 'A' , bb : 'Bb' , 'c-c' : 'cc' , d : 'd' , e : 'e' , f : 'ff' , } ) ; } ) ; test ( 'CaseInsensitiveObject get should get a lower-cased value' , ( ) => { const sut = new CaseInsensitiveObject ( ) ; sut [ 'A' ] = 'A' ; sut [ 'Bb' ] = 'Bb' ; sut [ 'c-C' ] = 'cc' ; sut [ 'd' ] = 'd' ; sut . E = 'e' ; sut . f = 'ff' ; expect ( sut . a ) . toEqual ( 'A' ) ; expect ( sut . A ) . toEqual ( 'A' ) ; expect ( sut [ 'a' ] ) . toEqual ( 'A' ) ; expect ( sut [ 'A' ] ) . toEqual ( 'A' ) ; expect ( sut . Bb ) . toEqual ( 'Bb' ) ; expect ( sut [ 'c-c' ] ) . toEqual ( 'cc' ) ; expect ( sut . d ) . toEqual ( 'd' ) ; expect ( sut . D ) . toEqual ( 'd' ) ; expect ( sut [ 'd' ] ) . toEqual ( 'd' ) ; expect ( sut [ 'D' ] ) . toEqual ( 'd' ) ; expect ( sut . e ) . toEqual ( 'e' ) ; expect ( sut . E ) . toEqual ( 'e' ) ; expect ( sut [ 'e' ] ) . toEqual ( 'e' ) ; expect ( sut [ 'E' ] ) . toEqual ( 'e' ) ; } ) ; test ( 'DefaultMultiValueObject get defaults correctly' , ( ) => { const sut = new DefaultMultiValueObject ( ) ; sut . a = [ 'a' ] ; sut . b = [ 'b' , 'B' ] ; expect ( sut . a ) . toEqual ( [ 'a' ] ) ; expect ( sut . b ) . toEqual ( [ 'b' , 'B' ] ) ; expect ( sut . c ) . toEqual ( [ ] ) ; } ) ;