-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: swap component refactor limits (#7588)
* feat: add limits tab, flag * feat: add unit test * fix: update snapshot
- Loading branch information
Showing
10 changed files
with
1,178 additions
and
632 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { TEST_ALLOWED_SLIPPAGE, TEST_TRADE_EXACT_INPUT } from 'test-utils/constants' | ||
import { render, screen } from 'test-utils/render' | ||
|
||
import SwapHeader, { SwapTab } from './SwapHeader' | ||
|
||
jest.mock('../../featureFlags/flags/limits', () => ({ useLimitsEnabled: () => true })) | ||
|
||
describe('SwapHeader.tsx', () => { | ||
it('matches base snapshot', () => { | ||
const { asFragment } = render( | ||
<SwapHeader | ||
trade={TEST_TRADE_EXACT_INPUT} | ||
selectedTab={SwapTab.Swap} | ||
autoSlippage={TEST_ALLOWED_SLIPPAGE} | ||
onClickTab={jest.fn()} | ||
/> | ||
) | ||
expect(asFragment()).toMatchSnapshot() | ||
expect(screen.getByText('Swap')).toBeInTheDocument() | ||
expect(screen.getByText('Buy')).toBeInTheDocument() | ||
expect(screen.getByText('Limit')).toBeInTheDocument() | ||
}) | ||
|
||
it('calls callback for switching tabs', () => { | ||
const onClickTab = jest.fn() | ||
render( | ||
<SwapHeader | ||
trade={TEST_TRADE_EXACT_INPUT} | ||
selectedTab={SwapTab.Swap} | ||
autoSlippage={TEST_ALLOWED_SLIPPAGE} | ||
onClickTab={onClickTab} | ||
/> | ||
) | ||
screen.getByText('Limit').click() | ||
expect(onClickTab).toHaveBeenCalledWith(SwapTab.Limit) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.