Skip to content

Commit

Permalink
test: switchToAndFromTokens action
Browse files Browse the repository at this point in the history
  • Loading branch information
micaelae committed Oct 10, 2024
1 parent 118fc34 commit 8668a19
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions ui/ducks/bridge/bridge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
setToToken,
setFromChain,
resetInputFields,
switchToAndFromTokens,
} from './actions';

const middleware = [thunk];
Expand Down Expand Up @@ -135,4 +136,32 @@ describe('Ducks - Bridge', () => {
});
});
});

describe('switchToAndFromTokens', () => {
it('switches to and from input values', async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const bridgeStore = configureMockStore<any>(middleware)(
createBridgeMockStore(
{},
{
toChainId: CHAIN_IDS.MAINNET,
fromToken: { symbol: 'WETH', address: '0x13341432' },
toToken: { symbol: 'USDC', address: '0x13341431' },
fromTokenInputValue: '10',
},
),
);
const state = bridgeStore.getState().bridge;
bridgeStore.dispatch(switchToAndFromTokens(CHAIN_IDS.POLYGON));
const actions = bridgeStore.getActions();
expect(actions[0].type).toStrictEqual('bridge/switchToAndFromTokens');
const newState = bridgeReducer(state, actions[0]);
expect(newState).toStrictEqual({
toChainId: CHAIN_IDS.POLYGON,
fromToken: { symbol: 'USDC', address: '0x13341431' },
toToken: { symbol: 'WETH', address: '0x13341432' },
fromTokenInputValue: null,
});
});
});
});

0 comments on commit 8668a19

Please sign in to comment.