Skip to content

Commit

Permalink
test: verify import wallet is not displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
theborakompanioni committed Sep 8, 2023
1 parent f66092f commit bcd33d0
Showing 1 changed file with 38 additions and 4 deletions.
42 changes: 38 additions & 4 deletions src/components/Wallets.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ describe('<Wallets />', () => {
beforeEach(() => {
const neverResolvingPromise = new Promise(() => {})
apiMock.getSession.mockResolvedValue(neverResolvingPromise)
apiMock.getGetinfo.mockResolvedValue({
ok: true,
json: () => Promise.resolve({ version: '0.9.10dev' }),
})
apiMock.getGetinfo.mockResolvedValue(neverResolvingPromise)
})

it('should render without errors', () => {
Expand Down Expand Up @@ -91,6 +88,10 @@ describe('<Wallets />', () => {
ok: true,
json: () => Promise.resolve({ wallets: [] }),
})
apiMock.getGetinfo.mockResolvedValueOnce({
ok: true,
json: () => Promise.resolve({ version: '0.9.10dev' }),
})

act(() => setup({}))

Expand Down Expand Up @@ -126,6 +127,10 @@ describe('<Wallets />', () => {
ok: true,
json: () => Promise.resolve({ wallets: ['wallet0.jmdat', 'wallet1.jmdat'] }),
})
apiMock.getGetinfo.mockResolvedValueOnce({
ok: true,
json: () => Promise.resolve({ version: '0.9.10dev' }),
})

act(() => setup({}))

Expand All @@ -146,6 +151,35 @@ describe('<Wallets />', () => {
expect(importWalletButton.classList.contains('btn-lg')).toBe(false)
})

it('should hide "Import Wallet"-button on unsupported backend version', async () => {
apiMock.getSession.mockResolvedValueOnce({
ok: true,
json: () =>
Promise.resolve({
session: false,
maker_running: false,
coinjoin_in_process: false,
wallet_name: 'None',
}),
})
apiMock.getWalletAll.mockResolvedValueOnce({
ok: true,
json: () => Promise.resolve({ wallets: [] }),
})
apiMock.getGetinfo.mockResolvedValueOnce({
ok: true,
json: () => Promise.resolve({ version: '0.9.9' }),
})

act(() => setup({}))

expect(screen.getByText('wallets.text_loading')).toBeInTheDocument()
await waitForElementToBeRemoved(screen.getByText('wallets.text_loading'))

expect(screen.queryByTestId('import-wallet-btn')).not.toBeInTheDocument()
expect(screen.getByTestId('new-wallet-btn')).toBeInTheDocument()
})

describe('<Wallets /> lock/unlock flow', () => {
const dummyWalletName = 'dummy.jmdat'
const dummyToken = 'dummyToken'
Expand Down

0 comments on commit bcd33d0

Please sign in to comment.