1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00
commons/client/src/components/atoms/Account.test.tsx

45 lines
1.4 KiB
TypeScript
Raw Normal View History

2019-04-30 19:19:28 +02:00
import React from 'react'
import { render } from '@testing-library/react'
2019-04-30 19:19:28 +02:00
import { toDataUrl } from 'ethereum-blockies'
import Account from './Account'
2019-07-12 00:24:29 +02:00
import { User } from '../../context'
import { userMockConnected } from '../../../__mocks__/user-mock'
2019-04-30 19:19:28 +02:00
describe('Account', () => {
it('renders without crashing', () => {
2019-07-12 00:24:29 +02:00
const { container } = render(
<User.Provider
value={{ ...userMockConnected, account: '0xxxxxxxxxxxxxxx' }}
>
<Account />
</User.Provider>
)
2019-04-30 19:19:28 +02:00
expect(container.firstChild).toBeInTheDocument()
})
it('outputs empty state without account', () => {
2019-07-12 00:24:29 +02:00
const { container } = render(
<User.Provider value={{ ...userMockConnected, account: '' }}>
<Account />
</User.Provider>
)
2019-04-30 19:19:28 +02:00
expect(container.firstChild).toHaveTextContent('No account selected')
})
it('outputs blockie img', () => {
const account = '0xxxxxxxxxxxxxxx'
const blockies = toDataUrl(account)
2019-07-12 00:24:29 +02:00
const { container } = render(
<User.Provider value={{ ...userMockConnected, account }}>
<Account />
</User.Provider>
)
2019-04-30 19:19:28 +02:00
expect(container.querySelector('.blockies')).toBeInTheDocument()
expect(container.querySelector('.blockies')).toHaveAttribute(
'src',
blockies
)
})
})