-
-
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 3053-integrate-nft-api-to-display-names-for-…
…nfts-within-simulations-on-mobile
- Loading branch information
Showing
31 changed files
with
1,146 additions
and
231 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
20.14.0 | ||
20.17.0 |
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
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
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
73 changes: 73 additions & 0 deletions
73
app/components/Views/ChangeInSimulationModal/ChangeInSimulationModal.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,73 @@ | ||
import React from 'react'; | ||
import { fireEvent } from '@testing-library/react-native'; | ||
|
||
import renderWithProvider, { | ||
DeepPartial, | ||
} from '../../../util/test/renderWithProvider'; | ||
import { backgroundState } from '../../../util/test/initial-root-state'; | ||
import ChangeInSimulationModal, { | ||
PROCEED_BUTTON_TEST_ID, | ||
REJECT_BUTTON_TEST_ID, | ||
} from './ChangeInSimulationModal'; | ||
import { RootState } from '../../../reducers'; | ||
|
||
jest.mock('react-redux', () => ({ | ||
...jest.requireActual('react-redux'), | ||
useDispatch: () => jest.fn(), | ||
})); | ||
|
||
jest.mock( | ||
'../../../component-library/components/BottomSheets/BottomSheet', | ||
() => | ||
({ children }: { children: React.ReactElement }) => | ||
<>{children}</>, | ||
); | ||
|
||
const NAVIGATION_PARAMS_MOCK = { | ||
params: { | ||
onProceed: jest.fn(), | ||
onReject: jest.fn(), | ||
}, | ||
}; | ||
|
||
const mockInitialState: DeepPartial<RootState> = { | ||
engine: { | ||
backgroundState: { | ||
...backgroundState, | ||
}, | ||
}, | ||
}; | ||
|
||
describe('ChangeInSimulationModal', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('render matches snapshot', () => { | ||
const { toJSON } = renderWithProvider( | ||
<ChangeInSimulationModal route={NAVIGATION_PARAMS_MOCK} />, | ||
{ | ||
state: mockInitialState, | ||
}, | ||
); | ||
expect(toJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
it('calls onProceed and onReject callbacks', () => { | ||
const mockOnReject = jest.fn(); | ||
const mockOnProceed = jest.fn(); | ||
const wrapper = renderWithProvider( | ||
<ChangeInSimulationModal | ||
route={{ params: { onProceed: mockOnProceed, onReject: mockOnReject } }} | ||
/>, | ||
{ | ||
state: mockInitialState, | ||
}, | ||
); | ||
fireEvent.press(wrapper.getByTestId(PROCEED_BUTTON_TEST_ID)); | ||
expect(mockOnProceed).toHaveBeenCalledTimes(1); | ||
|
||
fireEvent.press(wrapper.getByTestId(REJECT_BUTTON_TEST_ID)); | ||
expect(mockOnReject).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
93 changes: 93 additions & 0 deletions
93
app/components/Views/ChangeInSimulationModal/ChangeInSimulationModal.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,93 @@ | ||
import React, { useCallback, useRef } from 'react'; | ||
import { StyleSheet, View } from 'react-native'; | ||
import { strings } from '../../../../locales/i18n'; | ||
import BottomSheet, { | ||
BottomSheetRef, | ||
} from '../../../component-library/components/BottomSheets/BottomSheet'; | ||
import Button from '../../../component-library/components/Buttons/Button/Button'; | ||
import Icon, { | ||
IconSize, | ||
IconName, | ||
IconColor, | ||
} from '../../../component-library/components/Icons/Icon'; | ||
import { | ||
ButtonSize, | ||
ButtonVariants, | ||
ButtonWidthTypes, | ||
} from '../../../component-library/components/Buttons/Button'; | ||
import SheetHeader from '../../../component-library/components/Sheet/SheetHeader'; | ||
import Text from '../../../component-library/components/Texts/Text'; | ||
|
||
export const PROCEED_BUTTON_TEST_ID = 'proceed-button'; | ||
export const REJECT_BUTTON_TEST_ID = 'reject-button'; | ||
|
||
const createStyles = () => | ||
StyleSheet.create({ | ||
buttonsWrapper: { | ||
alignSelf: 'stretch', | ||
flexDirection: 'column', | ||
gap: 16, | ||
paddingTop: 24, | ||
}, | ||
wrapper: { | ||
alignItems: 'center', | ||
padding: 16, | ||
}, | ||
description: { | ||
textAlign: 'center', | ||
}, | ||
}); | ||
|
||
const ChangeInSimulationModal = ({ | ||
route, | ||
}: { | ||
route: { params: { onProceed: () => void; onReject: () => void } }; | ||
}) => { | ||
const styles = createStyles(); | ||
const sheetRef = useRef<BottomSheetRef>(null); | ||
const { onProceed, onReject } = route.params; | ||
|
||
const handleProceed = useCallback(() => { | ||
sheetRef.current?.onCloseBottomSheet(); | ||
onProceed(); | ||
}, [onProceed, sheetRef]); | ||
|
||
const handleReject = useCallback(() => { | ||
sheetRef.current?.onCloseBottomSheet(); | ||
onReject(); | ||
}, [onReject, sheetRef]); | ||
|
||
return ( | ||
<BottomSheet ref={sheetRef}> | ||
<View style={styles.wrapper}> | ||
<Icon | ||
color={IconColor.Error} | ||
name={IconName.Warning} | ||
size={IconSize.Xl} | ||
/> | ||
<SheetHeader title={strings('change_in_simulation_modal.title')} /> | ||
<Text>{strings('change_in_simulation_modal.description')}</Text> | ||
<View style={styles.buttonsWrapper}> | ||
<Button | ||
label={strings('change_in_simulation_modal.reject')} | ||
onPress={handleReject} | ||
size={ButtonSize.Lg} | ||
testID={REJECT_BUTTON_TEST_ID} | ||
variant={ButtonVariants.Primary} | ||
width={ButtonWidthTypes.Full} | ||
/> | ||
<Button | ||
label={strings('change_in_simulation_modal.proceed')} | ||
onPress={handleProceed} | ||
size={ButtonSize.Lg} | ||
testID={PROCEED_BUTTON_TEST_ID} | ||
variant={ButtonVariants.Secondary} | ||
width={ButtonWidthTypes.Full} | ||
/> | ||
</View> | ||
</View> | ||
</BottomSheet> | ||
); | ||
}; | ||
|
||
export default ChangeInSimulationModal; |
Oops, something went wrong.