@@ -4,7 +4,9 @@ import { Provider, connect } from '../../src/integrations/preact';
44
55const sleep = ms => new Promise ( r => setTimeout ( r , ms ) ) ;
66
7- describe ( 'integrations/preact' , ( ) => {
7+ const NO_CHILDREN = global . IS_PREACT_8 ? expect . anything ( ) : undefined ;
8+
9+ describe ( `integrations/preact${ global . IS_PREACT_8 ? '-8' : '' } ` , ( ) => {
810 describe ( '<Provider>' , ( ) => {
911 afterEach ( ( ) => {
1012 render ( null , document . body ) ;
@@ -35,9 +37,8 @@ describe('integrations/preact', () => {
3537 } ) ;
3638
3739 describe ( 'connect()' , ( ) => {
38- afterEach ( async ( ) => {
40+ afterEach ( ( ) => {
3941 render ( null , document . body ) ;
40- await sleep ( 1 ) ;
4142 } ) ;
4243
4344 it ( 'should pass mapped state as props' , ( ) => {
@@ -52,7 +53,7 @@ describe('integrations/preact', () => {
5253 document . body
5354 ) ;
5455 expect ( Child ) . toHaveBeenCalledWith (
55- { a : 'b' , store } ,
56+ { a : 'b' , store, children : NO_CHILDREN } ,
5657 expect . anything ( )
5758 ) ;
5859 expect ( store . subscribe ) . toBeCalled ( ) ;
@@ -70,7 +71,7 @@ describe('integrations/preact', () => {
7071 document . body
7172 ) ;
7273 expect ( Child ) . toHaveBeenCalledWith (
73- { a : 'b' , b : 'c' , store } ,
74+ { a : 'b' , b : 'c' , store, children : NO_CHILDREN } ,
7475 expect . anything ( )
7576 ) ;
7677 expect ( store . subscribe ) . toBeCalled ( ) ;
@@ -122,7 +123,7 @@ describe('integrations/preact', () => {
122123
123124 expect ( store . subscribe ) . toBeCalledWith ( expect . any ( Function ) ) ;
124125 expect ( Child ) . toHaveBeenCalledWith (
125- { store } ,
126+ { store, children : NO_CHILDREN } ,
126127 expect . anything ( )
127128 ) ;
128129
@@ -131,7 +132,7 @@ describe('integrations/preact', () => {
131132 store . setState ( { a : 'b' } ) ;
132133 await sleep ( 1 ) ;
133134 expect ( Child ) . toHaveBeenCalledWith (
134- { a : 'b' , store } ,
135+ { a : 'b' , store, children : NO_CHILDREN } ,
135136 expect . anything ( )
136137 ) ;
137138
@@ -158,20 +159,18 @@ describe('integrations/preact', () => {
158159 } ) ) ;
159160
160161 const ConnectedChild = connect ( mapStateToProps ) ( Child ) ;
161- const ref = { } ;
162162 render (
163163 < Provider store = { store } >
164- < ConnectedChild ref = { ref } />
164+ < ConnectedChild />
165165 </ Provider > ,
166166 document . body
167167 ) ;
168- let c = ref . current ;
169168
170169 expect ( mapStateToProps ) . toHaveBeenCalledTimes ( 1 ) ;
171- expect ( mapStateToProps ) . toHaveBeenCalledWith ( { } , { } ) ;
170+ expect ( mapStateToProps ) . toHaveBeenCalledWith ( { } , { children : NO_CHILDREN } ) ;
172171 // first render calls mapStateToProps
173172 expect ( Child ) . toHaveBeenCalledWith (
174- { mappings : 1 , store } ,
173+ { mappings : 1 , store, children : NO_CHILDREN } ,
175174 expect . anything ( )
176175 ) ;
177176
@@ -186,10 +185,10 @@ describe('integrations/preact', () => {
186185 ) ;
187186
188187 expect ( mapStateToProps ) . toHaveBeenCalledTimes ( 1 ) ;
189- expect ( mapStateToProps ) . toHaveBeenCalledWith ( { } , { a : 'b' } ) ;
188+ expect ( mapStateToProps ) . toHaveBeenCalledWith ( { } , { a : 'b' , children : NO_CHILDREN } ) ;
190189 // outer props were changed
191190 expect ( Child ) . toHaveBeenCalledWith (
192- { mappings : 2 , a : 'b' , store } ,
191+ { mappings : 2 , a : 'b' , store, children : NO_CHILDREN } ,
193192 expect . anything ( )
194193 ) ;
195194
@@ -204,11 +203,11 @@ describe('integrations/preact', () => {
204203 ) ;
205204
206205 expect ( mapStateToProps ) . toHaveBeenCalledTimes ( 1 ) ;
207- expect ( mapStateToProps ) . toHaveBeenCalledWith ( { } , { a : 'b' } ) ;
206+ expect ( mapStateToProps ) . toHaveBeenCalledWith ( { } , { a : 'b' , children : NO_CHILDREN } ) ;
208207
209208 // re-rendered, but outer props were not changed
210209 expect ( Child ) . toHaveBeenCalledWith (
211- { mappings : 3 , a : 'b' , store } ,
210+ { mappings : 3 , a : 'b' , store, children : NO_CHILDREN } ,
212211 expect . anything ( )
213212 ) ;
214213 } ) ;
0 commit comments