Skip to content

Commit

Permalink
fixup! feat(suite-native): Mobile Trade: Token picker modal visual stub
Browse files Browse the repository at this point in the history
  • Loading branch information
jbazant committed Feb 6, 2025
1 parent 0b34677 commit 64dcba0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 61 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ export type SheetHeaderTitleProps = {
} & RequireAllOrNone<{
onLeftButtonPress: () => void;
leftButtonIcon: IconName;
leftButtonA11yLabel: string;
}>;

export const SheetHeaderTitle = ({
onLeftButtonPress,
leftButtonIcon,
leftButtonA11yLabel,
children,
}: SheetHeaderTitleProps) => (
<HStack alignItems="center" justifyContent="space-between">
Expand All @@ -26,7 +28,7 @@ export const SheetHeaderTitle = ({
colorScheme="tertiaryElevation0"
size="medium"
accessibilityRole="button"
accessibilityLabel="Close"
accessibilityLabel={leftButtonA11yLabel}
/>
</Box>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState } from 'react';
import Animated, { FadeIn, FadeOut, LinearTransition } from 'react-native-reanimated';

import { BottomSheetGrabber, VStack } from '@suite-native/atoms';
import { Translation } from '@suite-native/intl';
import { Translation, useTranslate } from '@suite-native/intl';
import { prepareNativeStyle, useNativeStyles } from '@trezor/styles';

import { SheetHeaderTitle } from '../SheetHeaderTitle';
Expand All @@ -24,6 +24,7 @@ const wrapperStyle = prepareNativeStyle<{}>(({ spacings }) => ({

export const TradeableAssetsSheetHeader = ({ onClose }: TradeableAssetsSheetHeaderProps) => {
const { applyStyle } = useNativeStyles();
const { translate } = useTranslate();

const [isFilterActive, setIsFilterActive] = useState(false);
const [filterValue, setFilterValue] = useState('');
Expand All @@ -37,7 +38,11 @@ export const TradeableAssetsSheetHeader = ({ onClose }: TradeableAssetsSheetHead
entering={FadeIn.duration(FOCUS_ANIMATION_DURATION)}
exiting={FadeOut.duration(FOCUS_ANIMATION_DURATION)}
>
<SheetHeaderTitle leftButtonIcon="x" onLeftButtonPress={onClose}>
<SheetHeaderTitle
leftButtonIcon="x"
onLeftButtonPress={onClose}
leftButtonA11yLabel={translate('generic.buttons.close')}
>
<Translation id="moduleTrading.tradeableAssetsSheet.title" />
</SheetHeaderTitle>
</Animated.View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ import { fireEvent, render } from '@suite-native/test-utils';
import { TradeableAssetsSheetHeader } from '../TradeableAssetsSheetHeader';

describe('TradeableAssetsSheetHeader', () => {
const renderComponent = (onClose = jest.fn()) =>
render(<TradeableAssetsSheetHeader onClose={onClose} />);

it('should display "Coins" and do not display tabs by default', () => {
const { getByText, queryByText } = render(<TradeableAssetsSheetHeader />);
const { getByText, queryByText } = renderComponent();

expect(getByText('Coins')).toBeDefined();
expect(queryByText('All')).toBeNull();
});

it('should display tabs after focusing search input', () => {
const { getByPlaceholderText, getByText, queryByText } = render(
<TradeableAssetsSheetHeader />,
);
const { getByPlaceholderText, getByText, queryByText } = renderComponent();

fireEvent(getByPlaceholderText('Search'), 'focus');

Expand All @@ -22,16 +23,25 @@ describe('TradeableAssetsSheetHeader', () => {
});

it('should not display cancel button by default', () => {
const { queryByText } = render(<TradeableAssetsSheetHeader />);
const { queryByText } = renderComponent();

expect(queryByText('Cancel')).toBeNull();
});

it('should display cancel button after focusing search input', () => {
const { getByPlaceholderText, getByText } = render(<TradeableAssetsSheetHeader />);
const { getByPlaceholderText, getByText } = renderComponent();

fireEvent(getByPlaceholderText('Search'), 'focus');

expect(getByText('Cancel')).toBeDefined();
});

it('should call onClose when close button is pressed ', () => {
const onClose = jest.fn();
const { getByLabelText } = renderComponent(onClose);

fireEvent.press(getByLabelText('Close'));

expect(onClose).toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { TradingStackNavigator } from '../TradingStackNavigator';

describe('TradingStackNavigator', () => {
it('should render', async () => {
const { getByText } = renderWithStore(<TradingStackNavigator />);
await waitFor(() => expect(getByText('Trading placeholder')).toBeDefined());
const { getAllByText } = renderWithStore(<TradingStackNavigator />);
await waitFor(() => expect(getAllByText('Buy').length).toBe(2));
});
});

0 comments on commit 64dcba0

Please sign in to comment.