From 766c8a3e538d57b179a1e0b986129fa7b0fefd23 Mon Sep 17 00:00:00 2001 From: Thomas Huang Date: Thu, 9 Mar 2023 08:36:12 -0800 Subject: [PATCH] Force update mock state and render nfts item test fix (#18044) --- ui/components/app/nfts-items/nfts-items.test.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ui/components/app/nfts-items/nfts-items.test.js b/ui/components/app/nfts-items/nfts-items.test.js index 3cb67d2e1..a37013ac4 100644 --- a/ui/components/app/nfts-items/nfts-items.test.js +++ b/ui/components/app/nfts-items/nfts-items.test.js @@ -41,7 +41,7 @@ describe('NFTs Item Component', () => { const mockStore = configureMockStore([thunk])(mockState); it('should expand NFT collection showing individual NFTs', async () => { - const { queryByTestId, queryAllByTestId, rerender } = renderWithProvider( + const { queryByTestId, queryAllByTestId } = renderWithProvider( , mockStore, ); @@ -54,16 +54,20 @@ describe('NFTs Item Component', () => { fireEvent.click(collectionExpanderButton); - expect(updateNftDropDownState).toHaveBeenCalledWith({ + const expectedParams = { '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': { '0x5': { - '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': true, '0x495f947276749Ce646f68AC8c248420045cb7b5e': false, + '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': true, }, }, - }); + }; - rerender(, mockStore); + expect(updateNftDropDownState).toHaveBeenCalledWith(expectedParams); + + // Force rerender component with state/store update + mockState.metamask.nftsDropdownState = expectedParams; + renderWithProvider(, mockStore); expect(queryAllByTestId('nft-wrapper')).toHaveLength(8); });