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', () => {
35
35
} )
36
36
} )
37
37
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
+
38
59
it ( 'should allow methods to be passed as reducers' , ( ) => {
39
60
const upsertBook = createAction < BookModel > ( 'otherBooks/upsert' )
40
61
You can’t perform that action at this time.
0 commit comments