Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ describe('isValidPartialFiatAmountInput', () => {
});

describe('PerpsFiatHeroAmountInput', () => {
it('renders symbol and input for the given value', () => {
render(<PerpsFiatHeroAmountInput value="2.707414" onChange={jest.fn()} />);
expect(
screen.getByTestId('perps-fiat-hero-amount-symbol'),
).toBeInTheDocument();
expect(screen.getByTestId('perps-fiat-hero-amount-input')).toHaveValue(
'2.707414',
);
});

it('renders symbol and forwards input changes', () => {
const onChange = jest.fn();
render(<PerpsFiatHeroAmountInput value="" onChange={onChange} />);
Expand All @@ -46,9 +56,8 @@ describe('PerpsFiatHeroAmountInput', () => {
<PerpsFiatHeroAmountInput value="1" onChange={jest.fn()} isLoading />,
);

expect(
screen.getByTestId('perps-fiat-hero-amount-skeleton'),
).toBeInTheDocument();
const skeleton = screen.getByTestId('perps-fiat-hero-amount-skeleton');
expect(skeleton).toBeInTheDocument();
expect(
screen.queryByTestId('perps-fiat-hero-amount-input'),
).not.toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export const PerpsFiatHeroAmountSkeleton: React.FC = () => (
flexDirection={BoxFlexDirection.Row}
justifyContent={BoxJustifyContent.Center}
alignItems={BoxAlignItems.Center}
className="w-full"
style={{ minHeight: '70px' }}
data-testid="perps-fiat-hero-amount-skeleton"
>
Expand Down Expand Up @@ -134,6 +135,7 @@ export const PerpsFiatHeroAmountInput: React.FC<PerpsFiatHeroAmountInputProps> =
flexDirection={BoxFlexDirection.Row}
justifyContent={BoxJustifyContent.Center}
alignItems={BoxAlignItems.Center}
className="w-full"
Comment thread
abretonc7s marked this conversation as resolved.
style={{ minHeight: '70px' }}
>
<Text
Expand Down Expand Up @@ -162,7 +164,10 @@ export const PerpsFiatHeroAmountInput: React.FC<PerpsFiatHeroAmountInputProps> =
fontSize,
lineHeight,
fontWeight: 500,
width: `${Math.max(1, amountLength)}ch`,
minWidth: '1ch',
// field-sizing: content shrinks/grows the input to its text
// width, keeping the $ + amount pair centred in the flex row.
fieldSizing: 'content',
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated
} as React.CSSProperties
}
/>
Expand Down
Loading