@@ -46,7 +46,11 @@ describe('effects API', function() {
4646
4747 // a typical effect that updates the element state when finishing
4848
49- effect . register ( [ 'article' ] , 'mark' , async ( context , action ) => {
49+ effect . register ( [ 'article' ] , 'mark' , ( context , action ) => {
50+ return el => el . set ( 'marked' , action . type )
51+ } )
52+
53+ effect . register ( [ 'article' ] , 'mark-async' , async ( context , action ) => {
5054 await sleep ( 50 )
5155 return el => el . set ( 'marked' , action . type )
5256 } )
@@ -142,15 +146,25 @@ describe('effects API', function() {
142146 test ( 'Effect can return an updating fn state => newState' , async ( ) => {
143147 const focus = kernel . focusOn ( [ 'element1' , 'element2' , 'element3' ] )
144148
149+ expect ( focus . query ( ) . get ( 'marked' ) ) . not . toEqual ( 'mark' )
150+
145151 focus . dispatch ( { type : 'mark' } )
146152
153+ expect ( focus . query ( ) . get ( 'marked' ) ) . toEqual ( 'mark' )
154+ } )
155+
156+ test ( 'An async effect can return an updating fn state => newState' , async ( ) => {
157+ const focus = kernel . focusOn ( [ 'element1' , 'element2' , 'element3' ] )
158+
159+ focus . dispatch ( { type : 'mark-async' } )
160+
147161 await sleep ( 25 )
148162
149- expect ( focus . query ( ) . get ( 'marked' ) ) . not . toEqual ( 'mark' )
163+ expect ( focus . query ( ) . get ( 'marked' ) ) . not . toEqual ( 'mark-async ' )
150164
151165 await sleep ( 50 )
152166
153- expect ( focus . query ( ) . get ( 'marked' ) ) . toEqual ( 'mark' )
167+ expect ( focus . query ( ) . get ( 'marked' ) ) . toEqual ( 'mark-async ' )
154168 } )
155169
156170 test ( 'An async effect can return undefined' , ( ) => {
0 commit comments