Skip to content

Commit

Permalink
more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
finnian0826 committed Oct 11, 2024
1 parent 253d8c4 commit 928b893
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 2 deletions.
104 changes: 103 additions & 1 deletion src/earn/EarnPoolInfoScreen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import EarnPoolInfoScreen from 'src/earn/EarnPoolInfoScreen'
import { CICOFlow } from 'src/fiatExchanges/utils'
import { navigate } from 'src/navigator/NavigationService'
import { Screens } from 'src/navigator/Screens'
import { EarnPosition } from 'src/positions/types'
import { ClaimType, EarnPosition } from 'src/positions/types'
import { getFeatureGate, getMultichainFeatures } from 'src/statsig'
import { StatsigFeatureGates } from 'src/statsig/types'
import { NetworkId } from 'src/transactions/types'
Expand Down Expand Up @@ -757,4 +757,106 @@ describe('EarnPoolInfoScreen', () => {
})
// TODO (ACT-1389): Check that navigate called with confirmation screen for Claim
})
it('shows correct copy when ClaimType is Earnings', () => {
jest.mocked(getFeatureGate).mockImplementation(
(gate) =>
// gate === StatsigFeatureGates.ALLOW_EARN_PARTIAL_WITHDRAWAL ||
gate === StatsigFeatureGates.SHOW_POSITIONS
)
const { getByTestId, getByText } = render(
<Provider store={getStore()}>
<MockedNavigator
component={EarnPoolInfoScreen}
params={{
pool: {
...mockEarnPositions[0],
dataProps: {
...mockEarnPositions[0].dataProps,
claimType: ClaimType.Earnings,
},
balance: '100',
availableShortcutIds: ['withdraw', 'deposit', 'claim-rewards'],
},
}}
/>
</Provider>
)
fireEvent.press(getByTestId('WithdrawButton'))
expect(getByTestId('Earn/WithdrawBottomSheet')).toBeVisible()
expect(
getByText('earnFlow.poolInfoScreen.withdrawBottomSheet.withdrawDescription')
).toBeTruthy()
expect(getByText('earnFlow.poolInfoScreen.withdrawBottomSheet.claimEarnings')).toBeTruthy()
expect(
getByText('earnFlow.poolInfoScreen.withdrawBottomSheet.claimEarningsDescription')
).toBeTruthy()
expect(
getByText('earnFlow.poolInfoScreen.withdrawBottomSheet.exitWithEarningsDescription')
).toBeTruthy()
})
it('shows correct copy when ClaimType is Earnings', () => {

Check failure on line 797 in src/earn/EarnPoolInfoScreen.test.tsx

View workflow job for this annotation

GitHub Actions / Lint

Test title is used multiple times in the same describe block
jest.mocked(getFeatureGate).mockImplementation(
(gate) =>
// gate === StatsigFeatureGates.ALLOW_EARN_PARTIAL_WITHDRAWAL ||
gate === StatsigFeatureGates.SHOW_POSITIONS
)
const { getByTestId, getByText } = render(
<Provider store={getStore()}>
<MockedNavigator
component={EarnPoolInfoScreen}
params={{
pool: {
...mockEarnPositions[0],
dataProps: {
...mockEarnPositions[0].dataProps,
claimType: ClaimType.Rewards,
},
balance: '100',
availableShortcutIds: ['withdraw', 'deposit', 'claim-rewards'],
},
}}
/>
</Provider>
)
fireEvent.press(getByTestId('WithdrawButton'))
expect(getByTestId('Earn/WithdrawBottomSheet')).toBeVisible()
expect(getByText('earnFlow.poolInfoScreen.withdrawBottomSheet.claimRewards')).toBeTruthy()
expect(
getByText('earnFlow.poolInfoScreen.withdrawBottomSheet.claimRewardsDescription')
).toBeTruthy()
expect(
getByText('earnFlow.poolInfoScreen.withdrawBottomSheet.exitWithRewardsDescription')
).toBeTruthy()
})
it('shows correct copy when withdrawalIncludesClaim is true', () => {
jest.mocked(getFeatureGate).mockImplementation(
(gate) =>
// gate === StatsigFeatureGates.ALLOW_EARN_PARTIAL_WITHDRAWAL ||
gate === StatsigFeatureGates.SHOW_POSITIONS
)
const { getByTestId, getByText } = render(
<Provider store={getStore()}>
<MockedNavigator
component={EarnPoolInfoScreen}
params={{
pool: {
...mockEarnPositions[0],
dataProps: {
...mockEarnPositions[0].dataProps,
withdrawalIncludesClaim: true,
},
balance: '100',
availableShortcutIds: ['withdraw', 'deposit', 'claim-rewards'],
},
}}
/>
</Provider>
)
fireEvent.press(getByTestId('WithdrawButton'))
expect(getByTestId('Earn/WithdrawBottomSheet')).toBeVisible()
expect(getByText('earnFlow.poolInfoScreen.withdrawBottomSheet.withdrawAndClaim')).toBeTruthy()
expect(
getByText('earnFlow.poolInfoScreen.withdrawBottomSheet.withdrawAndClaimDescription')
).toBeTruthy()
})
})
2 changes: 1 addition & 1 deletion src/earn/WithdrawBottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function ClaimAction({
details:
claimType === ClaimType.Rewards
? t('earnFlow.poolInfoScreen.withdrawBottomSheet.claimRewardsDescription')
: t('earnFlow.poolInfoScreen.withdrawBottomSheet.claimRewardsDescription'),
: t('earnFlow.poolInfoScreen.withdrawBottomSheet.claimEarningsDescription'),
iconComponent: Claim,
onPress: () => {
AppAnalytics.track(EarnEvents.earn_select_withdraw_type, { type: 'claim' })
Expand Down

0 comments on commit 928b893

Please sign in to comment.