-
-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(suite-native): Introduce module-trading
- Loading branch information
Showing
19 changed files
with
168 additions
and
16 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
Binary file not shown.
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
38 changes: 35 additions & 3 deletions
38
suite-native/app/src/navigation/__tests__/AppTabNavigator.comp.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 |
---|---|---|
@@ -1,14 +1,46 @@ | ||
import { renderWithStore, waitFor } from '@suite-native/test-utils'; | ||
import { renderWithStore, waitFor, PreloadedState, fireEvent } from '@suite-native/test-utils'; | ||
import { FeatureFlag, featureFlagsInitialState } from '@suite-native/feature-flags'; | ||
|
||
import { AppTabNavigator } from '../AppTabNavigator'; | ||
|
||
describe('AppTabNavigator', () => { | ||
const renderTabs = async (preloadedState?: PreloadedState) => { | ||
const result = renderWithStore(<AppTabNavigator />, { preloadedState }); | ||
await waitFor(() => expect(result.getByText('Home')).toBeDefined()); | ||
|
||
return result; | ||
}; | ||
|
||
it('should render 3 buttons', async () => { | ||
const { getByText } = renderWithStore(<AppTabNavigator />); | ||
await waitFor(() => expect(getByText('Home')).toBeDefined()); | ||
const { getByText } = await renderTabs(); | ||
|
||
expect(getByText('Home')).toBeDefined(); | ||
expect(getByText('My assets')).toBeDefined(); | ||
expect(getByText('Settings')).toBeDefined(); | ||
}); | ||
|
||
it('should not render Trade tab when IsTradingEnabled is false', async () => { | ||
const { queryByText } = await renderTabs({ | ||
featureFlags: { | ||
...featureFlagsInitialState, | ||
[FeatureFlag.IsTradingEnabled]: false, | ||
}, | ||
}); | ||
|
||
expect(queryByText('Trade')).toBe(null); | ||
}); | ||
|
||
it('should render Trade tab when IsTradingEnabled is true', async () => { | ||
const { getByText } = await renderTabs({ | ||
featureFlags: { | ||
...featureFlagsInitialState, | ||
[FeatureFlag.IsTradingEnabled]: true, | ||
}, | ||
}); | ||
|
||
const tradeTab = getByText('Trade'); | ||
fireEvent.press(tradeTab); | ||
|
||
expect(getByText('Trading placeholder')).toBeDefined(); | ||
}); | ||
}); |
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,21 @@ | ||
{ | ||
"name": "@suite-native/module-trading", | ||
"version": "1.0.0", | ||
"private": true, | ||
"license": "See LICENSE.md in repo root", | ||
"sideEffects": false, | ||
"main": "src/index", | ||
"scripts": { | ||
"depcheck": "yarn g:depcheck", | ||
"type-check": "yarn g:tsc --build", | ||
"test:unit": "yarn g:jest -c ../../jest.config.native.js" | ||
}, | ||
"dependencies": { | ||
"@react-navigation/native-stack": "6.11.0", | ||
"@reduxjs/toolkit": "1.9.5", | ||
"@suite-native/navigation": "workspace:*", | ||
"@suite-native/test-utils": "workspace:*", | ||
"react": "18.2.0", | ||
"react-native": "0.76.1" | ||
} | ||
} |
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,7 @@ | ||
import { AsyncThunkAction } from '@reduxjs/toolkit'; | ||
|
||
declare module 'redux' { | ||
export interface Dispatch { | ||
<TThunk extends AsyncThunkAction<any, any, any>>(thunk: TThunk): ReturnType<TThunk>; | ||
} | ||
} |
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 @@ | ||
export * from './navigation/TradingStackNavigator'; |
24 changes: 24 additions & 0 deletions
24
suite-native/module-trading/src/navigation/TradingStackNavigator.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,24 @@ | ||
import { createNativeStackNavigator } from '@react-navigation/native-stack'; | ||
|
||
import { | ||
stackNavigationOptionsConfig, | ||
TradingStackParamList, | ||
TradingStackRoutes, | ||
} from '@suite-native/navigation'; | ||
|
||
import { TradingScreen } from '../screens/TradingScreen'; | ||
|
||
const TradingStack = createNativeStackNavigator<TradingStackParamList>(); | ||
|
||
export const TradingStackNavigator = () => ( | ||
<TradingStack.Navigator | ||
initialRouteName={TradingStackRoutes.Trading} | ||
screenOptions={stackNavigationOptionsConfig} | ||
> | ||
<TradingStack.Screen | ||
options={{ title: TradingStackRoutes.Trading }} | ||
name={TradingStackRoutes.Trading} | ||
component={TradingScreen} | ||
/> | ||
</TradingStack.Navigator> | ||
); |
10 changes: 10 additions & 0 deletions
10
suite-native/module-trading/src/navigation/__tests__/TradingStackNavigator.comp.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,10 @@ | ||
import { renderWithStore, waitFor } from '@suite-native/test-utils'; | ||
|
||
import { TradingStackNavigator } from '../TradingStackNavigator'; | ||
|
||
describe('TradingStackNavigator', () => { | ||
it('should render', async () => { | ||
const { getByText } = renderWithStore(<TradingStackNavigator />); | ||
await waitFor(() => expect(getByText('Trading placeholder')).toBeDefined()); | ||
}); | ||
}); |
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 React from 'react'; | ||
|
||
import { Screen } from '@suite-native/navigation'; | ||
import { Card, Text } from '@suite-native/atoms'; | ||
import { DeviceManagerScreenHeader } from '@suite-native/device-manager'; | ||
|
||
export const TradingScreen = () => ( | ||
<Screen header={<DeviceManagerScreenHeader />}> | ||
<Card> | ||
<Text>Trading placeholder</Text> | ||
</Card> | ||
</Screen> | ||
); |
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,9 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { "outDir": "libDev" }, | ||
"references": [ | ||
{ "path": "../navigation" }, | ||
{ "path": "../test-utils" } | ||
], | ||
"include": [".", "**/*.json"] | ||
} |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './StoreProvider'; | ||
export * from './appSlice'; | ||
export * from './store'; |
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