Skip to content

Commit

Permalink
Update RootState types
Browse files Browse the repository at this point in the history
  • Loading branch information
buberdds committed Apr 6, 2022
1 parent f1a48a5 commit 91fbea0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ describe('<NetworkSelector />', () => {
})

it('should allow switching network', async () => {
const spy = jest.spyOn(store, 'dispatch')
const dispatchSpy = jest.spyOn(store, 'dispatch')
const component = renderComponent(store)
expect(component.queryByTestId('active-network')).toContainHTML('Local')
userEvent.click(screen.getByTestId('network-selector'))

await waitFor(() => expect(screen.getByText('Testnet')))
screen.getByText('Testnet').click()

expect(spy).toHaveBeenCalledWith({
expect(dispatchSpy).toHaveBeenCalledWith({
payload: 'testnet',
type: 'network/selectNetwork',
})
Expand Down
2 changes: 1 addition & 1 deletion src/app/useRouteRedirects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jest.mock('react-router-dom', () => ({
}),
}))

describe('useStartTrial', () => {
describe('useRouteRedirects', () => {
beforeEach(() => {})

it('should redirects to account page', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/store/sagas.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { all } from 'redux-saga/effects'
import { all } from 'typed-redux-saga'

import { accountSaga } from 'app/state/account/saga'
import { networkSaga } from 'app/state/network/saga'
Expand Down
26 changes: 10 additions & 16 deletions src/types/RootState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,16 @@ import { StakingState } from 'app/state/staking/types'
import { FatalErrorState } from 'app/state/fatalerror/types'
// [IMPORT NEW CONTAINERSTATE ABOVE] < Needed for generating containers seamlessly

/*
Because the redux-injectors injects your reducers asynchronously somewhere in your code
You have to declare them here manually
Properties are optional because they are injected when the components are mounted sometime in your application's life.
So, not available always
*/
export interface RootState {
theme?: ThemeState
wallet?: WalletState
createWallet?: CreateWalletState
openWallet?: OpenWalletState
account?: AccountState
network?: NetworkState
transaction?: TransactionState
ledger?: LedgerState
staking?: StakingState
fatalError?: FatalErrorState
theme: ThemeState
wallet: WalletState
createWallet: CreateWalletState
openWallet: OpenWalletState
account: AccountState
network: NetworkState
transaction: TransactionState
ledger: LedgerState
staking: StakingState
fatalError: FatalErrorState
// [INSERT NEW REDUCER KEY ABOVE] < Needed for generating containers seamlessly
}
4 changes: 3 additions & 1 deletion src/utils/@reduxjs/toolkit.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { RootStateKeyType } from '../types/injector-typings'
import { createSlice as createSliceOriginal, SliceCaseReducers, CreateSliceOptions } from '@reduxjs/toolkit'
import { RootState } from 'types'

type RootStateKeyType = keyof RootState

/* Wrap createSlice with stricter Name options */

Expand Down

0 comments on commit 91fbea0

Please sign in to comment.