@@ -7,9 +7,6 @@ import { SagaTestWrapper } from '../../../../../config/tests/helpers.unit';
77global . TUMBLR_CLIENT_BASE_URL = 'http://test-site/' ;
88
99const responseItems = [ ] ;
10- const myTurnResponseItems = [ ] ;
11- const theirTurnResponseItems = [ ] ;
12- const queuedResponseItems = [ ] ;
1310
1411const initResponseData = ( ) => {
1512 for ( let i = 0 ; i < 5 ; i ++ ) {
@@ -20,17 +17,10 @@ const initResponseData = () => {
2017 isQueued : j % 2 === 0
2118 } ;
2219 responseItems . push ( responseItem ) ;
23- if ( responseItem . isQueued ) {
24- queuedResponseItems . push ( responseItem ) ;
25- } else if ( responseItem . isCallingCharactersTurn ) {
26- myTurnResponseItems . push ( responseItem ) ;
27- } else {
28- theirTurnResponseItems . push ( responseItem ) ;
29- }
3020 }
3121 }
3222} ;
33- const getInitialAction = ( turnFilter ) => {
23+ const getInitialAction = ( ) => {
3424 const requests = [ ] ;
3525 for ( let i = 0 ; i < 5 ; i ++ ) {
3626 for ( let j = 0 ; j < 10 ; j ++ ) {
@@ -44,10 +34,7 @@ const getInitialAction = (turnFilter) => {
4434 return {
4535 type : actions . FETCH_PUBLIC_THREADS_STATUS ,
4636 data : {
47- threadStatusRequestJson : JSON . stringify ( requests ) ,
48- view : {
49- turnFilter
50- }
37+ threadStatusRequestJson : JSON . stringify ( requests )
5138 }
5239 } ;
5340} ;
@@ -69,7 +56,7 @@ beforeAll(() => {
6956 initResponseData ( ) ;
7057} ) ;
7158describe ( 'saga behavior' , ( ) => {
72- it ( 'puts five empty chunks and success if no turn filter provided ' , ( ) => {
59+ it ( 'puts five chunks and success' , ( ) => {
7360 const saga = new SagaTestWrapper ( fetchPublicThreadsStatusSaga ) ;
7461 const action = getInitialAction ( ) ;
7562 setupSaga ( saga ) ;
@@ -78,67 +65,13 @@ describe('saga behavior', () => {
7865 const { effects } = result ;
7966 expect ( effects . put ) . toHaveLength ( 6 ) ;
8067 for ( let i = 0 ; i < 5 ; i ++ ) {
81- expect ( effects . put [ i ] . PUT . action . data ) . toEqual ( [ ] ) ;
68+ expect ( effects . put [ i ] . PUT . action . data ) . toHaveLength ( 10 ) ;
8269 }
8370 expect ( effects . put [ 5 ] . PUT . action . type ) . toEqual (
8471 actions . FETCHED_PUBLIC_THREADS_STATUS_SUCCESS
8572 ) ;
8673 } ) ;
8774 } ) ;
88- it ( 'puts filtered chunks and success if turn filter is my turn' , ( ) => {
89- const saga = new SagaTestWrapper ( fetchPublicThreadsStatusSaga ) ;
90- const action = getInitialAction ( { includeMyTurn : true } ) ;
91- setupSaga ( saga ) ;
92- return saga . execute ( action )
93- . then ( ( result ) => {
94- const { effects } = result ;
95- expect ( effects . put ) . toHaveLength ( 6 ) ;
96- expect ( effects . put [ 0 ] . PUT . action . data ) . toHaveLength ( 5 ) ;
97- expect ( effects . put [ 1 ] . PUT . action . data ) . toHaveLength ( 0 ) ;
98- expect ( effects . put [ 2 ] . PUT . action . data ) . toHaveLength ( 5 ) ;
99- expect ( effects . put [ 3 ] . PUT . action . data ) . toHaveLength ( 0 ) ;
100- expect ( effects . put [ 4 ] . PUT . action . data ) . toHaveLength ( 5 ) ;
101- expect ( effects . put [ 5 ] . PUT . action . type ) . toEqual (
102- actions . FETCHED_PUBLIC_THREADS_STATUS_SUCCESS
103- ) ;
104- } ) ;
105- } ) ;
106- it ( 'puts filtered chunks and success if turn filter is their turn' , ( ) => {
107- const saga = new SagaTestWrapper ( fetchPublicThreadsStatusSaga ) ;
108- const action = getInitialAction ( { includeTheirTurn : true } ) ;
109- setupSaga ( saga ) ;
110- return saga . execute ( action )
111- . then ( ( result ) => {
112- const { effects } = result ;
113- expect ( effects . put ) . toHaveLength ( 6 ) ;
114- expect ( effects . put [ 0 ] . PUT . action . data ) . toHaveLength ( 0 ) ;
115- expect ( effects . put [ 1 ] . PUT . action . data ) . toHaveLength ( 5 ) ;
116- expect ( effects . put [ 2 ] . PUT . action . data ) . toHaveLength ( 0 ) ;
117- expect ( effects . put [ 3 ] . PUT . action . data ) . toHaveLength ( 5 ) ;
118- expect ( effects . put [ 4 ] . PUT . action . data ) . toHaveLength ( 0 ) ;
119- expect ( effects . put [ 5 ] . PUT . action . type ) . toEqual (
120- actions . FETCHED_PUBLIC_THREADS_STATUS_SUCCESS
121- ) ;
122- } ) ;
123- } ) ;
124- it ( 'puts filtered chunks and success if turn filter is queue' , ( ) => {
125- const saga = new SagaTestWrapper ( fetchPublicThreadsStatusSaga ) ;
126- const action = getInitialAction ( { includeQueued : true } ) ;
127- setupSaga ( saga ) ;
128- return saga . execute ( action )
129- . then ( ( result ) => {
130- const { effects } = result ;
131- expect ( effects . put ) . toHaveLength ( 6 ) ;
132- expect ( effects . put [ 0 ] . PUT . action . data ) . toHaveLength ( 5 ) ;
133- expect ( effects . put [ 1 ] . PUT . action . data ) . toHaveLength ( 5 ) ;
134- expect ( effects . put [ 2 ] . PUT . action . data ) . toHaveLength ( 5 ) ;
135- expect ( effects . put [ 3 ] . PUT . action . data ) . toHaveLength ( 5 ) ;
136- expect ( effects . put [ 4 ] . PUT . action . data ) . toHaveLength ( 5 ) ;
137- expect ( effects . put [ 5 ] . PUT . action . type ) . toEqual (
138- actions . FETCHED_PUBLIC_THREADS_STATUS_SUCCESS
139- ) ;
140- } ) ;
141- } ) ;
14275 it ( 'should dispatch general failure on pre-chunk exception' , ( ) => {
14376 const saga = new SagaTestWrapper ( fetchPublicThreadsStatusSaga ) ;
14477 saga . expectPut ( {
0 commit comments