Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/components/Send/__tests__/SendToken.test.js
import React from 'react'; | import React from 'react'; | ||||
import renderer from 'react-test-renderer'; | import renderer from 'react-test-renderer'; | ||||
import { ThemeProvider } from 'styled-components'; | import { ThemeProvider } from 'styled-components'; | ||||
import { theme } from '@assets/styles/theme'; | import { theme } from '@assets/styles/theme'; | ||||
import SendToken from '@components/Send/SendToken'; | import SendToken from '@components/Send/SendToken'; | ||||
import BCHJS from '@psf/bch-js'; | import BCHJS from '@psf/bch-js'; | ||||
import { | import { | ||||
walletWithBalancesAndTokens, | walletWithBalancesAndTokens, | ||||
walletWithBalancesAndTokensWithCorrectState, | walletWithBalancesAndTokensWithCorrectState, | ||||
walletWithBalancesAndTokensWithEmptyState, | |||||
} from '../../Wallet/__mocks__/walletAndBalancesMock'; | } from '../../Wallet/__mocks__/walletAndBalancesMock'; | ||||
import { BrowserRouter as Router } from 'react-router-dom'; | import { BrowserRouter as Router } from 'react-router-dom'; | ||||
let realUseContext; | let realUseContext; | ||||
let useContextMock; | let useContextMock; | ||||
beforeEach(() => { | beforeEach(() => { | ||||
realUseContext = React.useContext; | realUseContext = React.useContext; | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | const component = renderer.create( | ||||
/> | /> | ||||
</Router> | </Router> | ||||
</ThemeProvider>, | </ThemeProvider>, | ||||
); | ); | ||||
let tree = component.toJSON(); | let tree = component.toJSON(); | ||||
expect(tree).toMatchSnapshot(); | expect(tree).toMatchSnapshot(); | ||||
}); | }); | ||||
test('Wallet with BCH balances and tokens and state field, but no params in state', () => { | |||||
const testBCH = new BCHJS(); | |||||
useContextMock.mockReturnValue(walletWithBalancesAndTokensWithEmptyState); | |||||
const component = renderer.create( | |||||
<ThemeProvider theme={theme}> | |||||
<Router> | |||||
<SendToken | |||||
tokenId={ | |||||
'bd1acc4c986de57af8d6d2a64aecad8c30ee80f37ae9d066d758923732ddc9ba' | |||||
} | |||||
jestBCH={testBCH} | |||||
/> | |||||
</Router> | |||||
</ThemeProvider>, | |||||
); | |||||
let tree = component.toJSON(); | |||||
expect(tree).toMatchSnapshot(); | |||||
}); | |||||
test('Without wallet defined', () => { | test('Without wallet defined', () => { | ||||
const testBCH = new BCHJS(); | const testBCH = new BCHJS(); | ||||
useContextMock.mockReturnValue({ | useContextMock.mockReturnValue({ | ||||
wallet: {}, | wallet: {}, | ||||
balances: { totalBalance: 0 }, | balances: { totalBalance: 0 }, | ||||
loading: false, | loading: false, | ||||
}); | }); | ||||
const component = renderer.create( | const component = renderer.create( | ||||
Show All 14 Lines |