Skip to content

Commit

Permalink
Merge pull request #9592 from google/fix/9590-non-iterable-instance-e…
Browse files Browse the repository at this point in the history
…rror
  • Loading branch information
nfmohit authored Oct 31, 2024
2 parents 06d6607 + a3c1ce8 commit 9ae6f84
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
11 changes: 4 additions & 7 deletions assets/js/modules/analytics-4/datastore/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,12 @@ const fetchGetAccountSummariesStore = createFetchStore( {
return { pageToken };
},
reducerCallback( state, response ) {
const { accountSummaries: newAccountSummaries } = response;
const mergedAccountSummaries = [
...( state.accountSummaries || [] ),
...newAccountSummaries,
];

return {
...state,
accountSummaries: mergedAccountSummaries,
accountSummaries: [
...( state.accountSummaries || [] ),
...( response.accountSummaries || [] ),
],
};
},
} );
Expand Down
15 changes: 15 additions & 0 deletions assets/js/modules/analytics-4/datastore/accounts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,21 @@ describe( 'modules/analytics-4 accounts', () => {
} );
} );

describe( 'fetchGetAccountSummaries', () => {
it( 'supports when no account summaries returned', async () => {
fetchMock.get( accountSummariesEndpoint, {
body: { nextPageToken: null },
status: 200,
} );
const { fetchGetAccountSummaries } =
registry.dispatch( MODULES_ANALYTICS_4 );

await fetchGetAccountSummaries();

expect( store.getState().accountSummaries ).toEqual( [] );
} );
} );

describe( 'transformAndSortAccountSummaries', () => {
it( 'should create an action to transform and sort account summaries', async () => {
registry
Expand Down

0 comments on commit 9ae6f84

Please sign in to comment.