@@ -607,6 +607,25 @@ describe('Sorted State Adapter', () => {
607607 expect ( withOneSorted ) . toEqual ( withOneUnsorted ) ;
608608 } )
609609
610+ it ( 'should work consistent with Unsorted State Adapter adding duplicate ids' , ( ) => {
611+ const unsortedAdaptor = createEntityAdapter ( {
612+ selectId : ( book : BookModel ) => book . id
613+ } ) ;
614+
615+ const firstEntry = { id : AClockworkOrange . id , author : TheHobbit . author }
616+ const secondEntry = { id : AClockworkOrange . id , title : 'Zack' }
617+ const withNothingSorted = adapter . setAll ( state , [ TheHobbit ] ) ;
618+ const withNothingUnsorted = unsortedAdaptor . setAll ( state , [ TheHobbit ] ) ;
619+ const withOneSorted = adapter . setMany ( withNothingSorted , [
620+ { ...AClockworkOrange , ...firstEntry , id : 'th' } , { ...AClockworkOrange , ...secondEntry , id : 'th' }
621+ ] )
622+ const withOneUnsorted = unsortedAdaptor . setMany ( withNothingUnsorted , [
623+ { ...AClockworkOrange , ...firstEntry , id : 'th' } , { ...AClockworkOrange , ...secondEntry , id : 'th' }
624+ ] )
625+
626+ expect ( withOneSorted ) . toEqual ( withOneUnsorted ) ;
627+ } )
628+
610629 it ( 'should let you set many entities in the state when passing in a dictionary' , ( ) => {
611630 const changeWithoutAuthor = { id : TheHobbit . id , title : 'Silmarillion' }
612631 const withMany = adapter . setAll ( state , [ TheHobbit ] )
0 commit comments