Skip to content

Commit 3ba772b

Browse files
authored
fix: AccountSelectorList test (#15085)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** This test was skipped during the [react native upgrade](https://github.com/MetaMask/metamask-mobile/pull/13771/files#). I have since fixed the test and removed the it.skip. The fix for this was to remove the manual mock of React.useRef ## **Related issues** Fixes: ## **Manual testing steps** 1. checkout this branch 2. run yarn setup 3. then run yarn jest app/components/UI/AccountSelectorList/AccountSelectorList.test.tsx 4. all the tests should pass ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <img width="766" alt="Screenshot 2025-05-02 at 11 45 08 AM" src="https://github.com/user-attachments/assets/86f8274d-a817-4ab3-9ac8-108d0733b809" /> ### **After** <img width="767" alt="Screenshot 2025-05-02 at 11 44 41 AM" src="https://github.com/user-attachments/assets/fc67e27b-83ab-4e4c-8f94-df822f8a186c" /> ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
1 parent 1aef6b5 commit 3ba772b

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

app/components/UI/AccountSelectorList/AccountSelectorList.test.tsx

+1-14
Original file line numberDiff line numberDiff line change
@@ -923,18 +923,8 @@ describe('AccountSelectorList', () => {
923923
});
924924

925925
// TODO: fix this test
926-
it.skip('should not auto-scroll when isAutoScrollEnabled is false', async () => {
927-
// Create a mock FlatList ref with scrollToOffset method
926+
it('should not auto-scroll when isAutoScrollEnabled is false', async () => {
928927
const mockScrollToOffset = jest.fn();
929-
const mockFlatListRef = {
930-
current: {
931-
scrollToOffset: mockScrollToOffset,
932-
},
933-
};
934-
935-
// Override React.useRef to return our mock reference
936-
const originalUseRef = React.useRef;
937-
jest.spyOn(React, 'useRef').mockImplementation(() => mockFlatListRef);
938928

939929
// Create test component with auto-scroll disabled
940930
const AccountSelectorListNoAutoScrollTest: React.FC = () => {
@@ -960,9 +950,6 @@ describe('AccountSelectorList', () => {
960950

961951
// Verify that scrollToOffset was not called
962952
expect(mockScrollToOffset).not.toHaveBeenCalled();
963-
964-
// Restore the original useRef implementation
965-
React.useRef = originalUseRef;
966953
});
967954

968955
it('should display ENS name instead of account name when available', async () => {

0 commit comments

Comments
 (0)