Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions app/components/UI/Tokens/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -394,24 +394,21 @@ describe('Tokens', () => {
});

describe('showOnlyMusd (Cash view)', () => {
it('passes showAddToken false and hideSort true to TokenListControlBar', async () => {
it('does not render TokenListControlBar when showOnlyMusd', async () => {
const { mockSelectSortedAssetsBySelectedAccountGroup } =
arrangeMockSelectors();
mockSelectSortedAssetsBySelectedAccountGroup.mockReturnValue([]);

renderComponent(initialState, true, true);
const { queryByTestId } = renderComponent(initialState, true, true);

await waitFor(() => {
expect(
TokenListControlBarModule.TokenListControlBar,
).toHaveBeenCalledWith(
expect.objectContaining({
showAddToken: false,
hideSort: true,
}),
expect.anything(),
);
expect(queryByTestId('tokens-empty-state')).toBeOnTheScreen();
});

expect(queryByTestId('token-list-control-bar')).toBeNull();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test uses toBeNull instead of not.toBeOnTheScreen

Low Severity

The assertion expect(queryByTestId('token-list-control-bar')).toBeNull() uses toBeNull() to check element absence. The unit testing guidelines require using not.toBeOnTheScreen() for absence checks, as it communicates intent more clearly and aligns with the project's preferred matcher conventions.

Fix in Cursor Fix in Web

Triggered by project rule: Unit Testing Guidelines

Reviewed by Cursor Bugbot for commit fb57af4. Configure here.

expect(
TokenListControlBarModule.TokenListControlBar,
).not.toHaveBeenCalled();
});

it('does not render add token button when showOnlyMusd', async () => {
Expand Down
14 changes: 8 additions & 6 deletions app/components/UI/Tokens/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,14 @@ const Tokens = forwardRef<TabRefreshHandle, TokensProps>(
}
testID={WalletViewSelectorsIDs.TOKENS_CONTAINER}
>
<TokenListControlBar
goToAddToken={goToAddToken}
showAddToken={!showOnlyMusd}
hideSort={showOnlyMusd}
style={isFullView ? tw`px-4 pb-4` : undefined}
/>
{!showOnlyMusd && (
<TokenListControlBar
goToAddToken={goToAddToken}
showAddToken={!showOnlyMusd}
hideSort={showOnlyMusd}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant props always equal their default values

Low Severity

Inside the {!showOnlyMusd && (...)} guard, showAddToken={!showOnlyMusd} always evaluates to true and hideSort={showOnlyMusd} always evaluates to false, since the block only executes when showOnlyMusd is falsy. Both values match the component's defaults (showAddToken = true, hideSort = false), making these props redundant dead code that misleadingly suggests they could vary.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit fb57af4. Configure here.

style={isFullView ? tw`px-4 pb-4` : undefined}
/>
)}
{tokenContent}
<ScamWarningModal
showScamWarningModal={showScamWarningModal}
Expand Down
Loading