-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into brian/multichain-token-rates
- Loading branch information
Showing
29 changed files
with
1,158 additions
and
405 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
16 changes: 16 additions & 0 deletions
16
app/components/UI/Stake/components/GasImpactModal/GasImpactModal.styles.ts
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,16 @@ | ||
import { StyleSheet } from 'react-native'; | ||
|
||
const styleSheet = () => | ||
StyleSheet.create({ | ||
container: { | ||
paddingHorizontal: 16, | ||
}, | ||
content: { | ||
paddingBottom: 16, | ||
}, | ||
footer: { | ||
paddingBottom: 16, | ||
}, | ||
}); | ||
|
||
export default styleSheet; |
75 changes: 75 additions & 0 deletions
75
app/components/UI/Stake/components/GasImpactModal/GasImpactModal.test.tsx
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,75 @@ | ||
import React from 'react'; | ||
import renderWithProvider from '../../../../../util/test/renderWithProvider'; | ||
import { GasImpactModalProps } from './GasImpactModal.types'; | ||
import GasImpactModal from './index'; | ||
import { Metrics, SafeAreaProvider } from 'react-native-safe-area-context'; | ||
import { fireEvent } from '@testing-library/react-native'; | ||
import { strings } from '../../../../../../locales/i18n'; | ||
|
||
const mockNavigate = jest.fn(); | ||
const mockGoBack = jest.fn(); | ||
|
||
jest.mock('@react-navigation/native', () => { | ||
const actualReactNavigation = jest.requireActual('@react-navigation/native'); | ||
return { | ||
...actualReactNavigation, | ||
useNavigation: () => ({ | ||
navigate: mockNavigate, | ||
goBack: mockGoBack, | ||
}), | ||
}; | ||
}); | ||
|
||
const props: GasImpactModalProps = { | ||
route: { | ||
key: '1', | ||
params: { | ||
amountWei: '3210000000000000', | ||
amountFiat: '7.46', | ||
annualRewardRate: '2.5%', | ||
annualRewardsETH: '2.5 ETH', | ||
annualRewardsFiat: '$5000', | ||
}, | ||
name: 'params', | ||
}, | ||
}; | ||
|
||
const initialMetrics: Metrics = { | ||
frame: { x: 0, y: 0, width: 320, height: 640 }, | ||
insets: { top: 0, left: 0, right: 0, bottom: 0 }, | ||
}; | ||
|
||
const renderGasImpactModal = () => | ||
renderWithProvider( | ||
<SafeAreaProvider initialMetrics={initialMetrics}> | ||
<GasImpactModal {...props} />, | ||
</SafeAreaProvider>, | ||
); | ||
|
||
describe('GasImpactModal', () => { | ||
it('render matches snapshot', () => { | ||
const { toJSON } = renderGasImpactModal(); | ||
|
||
expect(toJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
it('navigates to StakeConfirmationView on approval', () => { | ||
const { getByText } = renderGasImpactModal(); | ||
|
||
const proceedAnywayButton = getByText(strings('stake.proceed_anyway')); | ||
|
||
fireEvent.press(proceedAnywayButton); | ||
|
||
expect(mockNavigate).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('closes gas impact modal on cancel', () => { | ||
const { getByText } = renderGasImpactModal(); | ||
|
||
const proceedAnywayButton = getByText(strings('stake.cancel')); | ||
|
||
fireEvent.press(proceedAnywayButton); | ||
|
||
expect(mockGoBack).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
13 changes: 13 additions & 0 deletions
13
app/components/UI/Stake/components/GasImpactModal/GasImpactModal.types.ts
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,13 @@ | ||
import { RouteProp } from '@react-navigation/native'; | ||
|
||
interface GasImpactModalRouteParams { | ||
amountWei: string; | ||
amountFiat: string; | ||
annualRewardsETH: string; | ||
annualRewardsFiat: string; | ||
annualRewardRate: string; | ||
} | ||
|
||
export interface GasImpactModalProps { | ||
route: RouteProp<{ params: GasImpactModalRouteParams }, 'params'>; | ||
} |
Oops, something went wrong.