File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
packages/toolkit/src/entities/tests Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,27 @@ describe('Entity State', () => {
3535 } )
3636 } )
3737
38+ it ( 'should let you provide initial entities' , ( ) => {
39+ const book1 : BookModel = { id : 'a' , title : 'First' }
40+
41+ const initialState = adapter . getInitialState ( undefined , [ book1 ] )
42+
43+ expect ( initialState ) . toEqual ( {
44+ ids : [ book1 . id ] ,
45+ entities : { [ book1 . id ] : book1 } ,
46+ } )
47+
48+ const additionalProperties = { isHydrated : true }
49+
50+ const initialState2 = adapter . getInitialState ( additionalProperties , [ book1 ] )
51+
52+ expect ( initialState2 ) . toEqual ( {
53+ ...additionalProperties ,
54+ ids : [ book1 . id ] ,
55+ entities : { [ book1 . id ] : book1 } ,
56+ } )
57+ } )
58+
3859 it ( 'should allow methods to be passed as reducers' , ( ) => {
3960 const upsertBook = createAction < BookModel > ( 'otherBooks/upsert' )
4061
You can’t perform that action at this time.
0 commit comments