import * as O from '.' ; describe ( 'indexed' , ( ) => { type Source = string [ ] ; const source = [ 'foo' , 'bar' , 'baz' ] ; const iso = O . indexed ; type Focus = [ number , string ] [ ] ; it ( 'get' , ( ) => { const result = O . get ( iso , source ) ; expect ( result ) . toEqual ( [ [ 0 , 'foo' ] , [ 1 , 'bar' ] , [ 2 , 'baz' ] , ] ) ; } ) ; describe ( 'set - monomorphic' , ( ) => { it ( 'already in order' , ( ) => { const value = [ [ 0 , 'FOO' ] , [ 1 , 'BAR' ] , [ 2 , 'BAZ' ] , ] ; const result = O . set ( iso , value , source ) ; expect ( result ) . toEqual ( [ 'FOO' , 'BAR' , 'BAZ' ] ) ; } ) ; it ( 'contiguous 0-based indexes' , ( ) => { const value = [ [ 1 , 'foo' ] , [ 0 , 'bar' ] , [ 3 , 'baz' ] , [ 2 , 'quux' ] , ] ; const result = O . set ( iso , value , source ) ; expect ( result ) . toEqual ( [ 'bar' , 'foo' , 'quux' , 'baz' ] ) ; } ) ; it ( 'non-contiguous indexes' , ( ) => { const value = [ [ 23 , 'foo' ] , [ 99 , 'bar' ] , [ 21 , 'baz' ] , [ 60 , 'quux' ] , ] ; const result = O . set ( iso , value , source ) ; expect ( result ) . toEqual ( [ 'baz' , 'foo' , 'quux' , 'bar' ] ) ; } ) ; it ( 'same index twice takes the last' , ( ) => { const value = [ [ 1 , 'foo' ] , [ 2 , 'bar' ] , [ 1 , 'baz' ] , [ 3 , 'quux' ] , ] ; const result = O . set ( iso , value , source ) ; expect ( result ) . toEqual ( [ 'baz' , 'bar' , 'quux' ] ) ; } ) ; } ) ; type Target = { foo : string ; } [ ] ; it ( 'set - polymorphic' , ( ) => { const value = [ [ 3 , { foo : 'bar' } ] , [ 2 , { foo : 'baz' } ] , [ 1 , { foo : 'quux' } ] , ] ; const result = O . set ( iso , value , source ) ; expect ( result ) . toEqual ( [ { foo : 'quux' } , { foo : 'baz' } , { foo : 'bar' } ] ) ; } ) ; } ) ;