File tree Expand file tree Collapse file tree 2 files changed +23
-9
lines changed
packages/node_modules/overmind/src/config Expand file tree Collapse file tree 2 files changed +23
-9
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,18 @@ describe('Config', () => {
9595 expect ( merged . state . configB . bar ) . toEqual ( 'baz' )
9696 } )
9797
98+ test ( 'should merge without root state' , ( ) => {
99+ const configA = { }
100+ const configB = {
101+ state : {
102+ bar : 'baz' ,
103+ } ,
104+ }
105+ const merged = merge ( configA , namespaced ( { configB } ) )
106+
107+ expect ( merged . state . configB . bar ) . toEqual ( 'baz' )
108+ } )
109+
98110 test ( 'should keep context when lazy loading namespaces' , async ( ) => {
99111 const config = {
100112 state : {
@@ -103,20 +115,21 @@ describe('Config', () => {
103115 actions : {
104116 changeFoo ( context ) {
105117 context . state . config . foo = 'bar2'
106- }
107- }
118+ } ,
119+ } ,
108120 }
109-
110- const overmind = createOvermindMock ( lazy ( {
111- config : ( ) => Promise . resolve ( config )
112- } ) )
121+
122+ const overmind = createOvermindMock (
123+ lazy ( {
124+ config : ( ) => Promise . resolve ( config ) ,
125+ } )
126+ )
113127
114128 await overmind . onInitialize ( )
115129
116130 await overmind . actions . lazy . loadConfig ( 'config' )
117131 // @ts -ignore
118132 overmind . actions . config . changeFoo ( )
119133 expect ( overmind . state . config ! . foo ) . toEqual ( 'bar2' )
120-
121134 } )
122135} )
Original file line number Diff line number Diff line change @@ -123,8 +123,6 @@ export function merge<
123123 configI : I
124124) : A & B & C & D & E & F & G & H & I
125125
126-
127-
128126export function merge ( ...configurations : IConfiguration [ ] ) : IConfiguration {
129127 const initializers = configurations . reduce (
130128 ( aggr , config ) =>
@@ -178,6 +176,9 @@ export function merge(...configurations: IConfiguration[]): IConfiguration {
178176 }
179177 } ,
180178 {
179+ state : { } ,
180+ actions : { } ,
181+ effects : { } ,
181182 ...rootConfiguration ,
182183 onInitialize : initializers . length
183184 ? ( context , value ) =>
You can’t perform that action at this time.
0 commit comments