@@ -27,6 +27,21 @@ const streamActionSpy = jest.spyOn(actions, 'stream');
2727const mockDispatch = jest . fn ( ) ;
2828
2929describe ( 'streamFetchye' , ( ) => {
30+ const originalWindow = global . window ;
31+
32+ beforeEach ( ( ) => {
33+ jest . clearAllMocks ( ) ;
34+ Object . defineProperty ( global , 'window' , {
35+ value : undefined ,
36+ configurable : true ,
37+ writable : true ,
38+ } ) ;
39+ } ) ;
40+
41+ afterEach ( ( ) => {
42+ global . window = originalWindow ;
43+ } ) ;
44+
3045 it ( 'should return a one-app-thunk that dispatches an action resolving to the passed in thunk' , async ( ) => {
3146 expect . assertions ( 2 ) ;
3247
@@ -63,4 +78,21 @@ describe('streamFetchye', () => {
6378 ) ;
6479 expect ( fetchyeThunk ) . toHaveBeenCalledWith ( ...fetchyeParams . slice ( 1 ) ) ;
6580 } ) ;
81+
82+ it ( 'should not dispatch the stream action on the client' , async ( ) => {
83+ expect . assertions ( 1 ) ;
84+
85+ global . window = originalWindow ;
86+
87+ const fetchyeThunk = jest . fn ( ) ;
88+ fetchyeThunk . mockResolvedValue ( Symbol ( 'fetchRequest' ) ) ;
89+
90+ const fetchyeParams = [ fetchyeThunk , Symbol ( 'fetchyeArgs - key' ) , Symbol ( 'fetchyeArgs - options' ) , Symbol ( 'fetchyeArgs - fetcher' ) ] ;
91+ const streamFetchyeThunk = streamFetchye ( ...fetchyeParams ) ;
92+ const thunkParams = [ mockDispatch , Symbol ( 'getState' ) , Symbol ( 'fetchClient' ) ] ;
93+ await streamFetchyeThunk (
94+ fetchyeThunk , thunkParams [ 0 ] , thunkParams [ 1 ] , { fetchClient : thunkParams [ 2 ] }
95+ ) ;
96+ expect ( streamActionSpy ) . not . toHaveBeenCalled ( ) ;
97+ } ) ;
6698} ) ;
0 commit comments