1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

fix AssetFile unit test

This commit is contained in:
Matthias Kretschmann 2019-07-16 14:50:30 +02:00
parent 69d8c28858
commit c1ff41b711
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -5,9 +5,10 @@ import { render, fireEvent } from '@testing-library/react'
import { DDO } from '@oceanprotocol/squid' import { DDO } from '@oceanprotocol/squid'
import { StateMock } from '@react-mock/state' import { StateMock } from '@react-mock/state'
import ReactGA from 'react-ga' import ReactGA from 'react-ga'
import { User } from '../../../context' import { User, Market } from '../../../context'
import AssetFile, { messages } from './AssetFile' import AssetFile, { messages } from './AssetFile'
import { userMockConnected } from '../../../../__mocks__/user-mock' import { userMockConnected } from '../../../../__mocks__/user-mock'
import { marketMock } from '../../../../__mocks__/market-mock'
const file = { const file = {
index: 0, index: 0,
@ -39,7 +40,9 @@ describe('AssetFile', () => {
it('button to be enabled when connected', async () => { it('button to be enabled when connected', async () => {
const { getByText } = render( const { getByText } = render(
<User.Provider value={userMockConnected}> <User.Provider value={userMockConnected}>
<AssetFile file={file} ddo={ddo} /> <Market.Provider value={marketMock}>
<AssetFile file={file} ddo={ddo} />
</Market.Provider>
</User.Provider> </User.Provider>
) )
const button = getByText('Get file') const button = getByText('Get file')
@ -50,12 +53,12 @@ describe('AssetFile', () => {
it('renders feedback message: initial', async () => { it('renders feedback message: initial', async () => {
const { container } = render( const { container } = render(
<StateMock state={{ isLoading: true, step: null }}> <StateMock state={{ isLoading: true, step: 99 }}>
<AssetFile file={file} ddo={ddo} /> <AssetFile file={file} ddo={ddo} />
</StateMock> </StateMock>
) )
expect(container.querySelector('.spinner')).toHaveTextContent( expect(container.querySelector('.spinner')).toHaveTextContent(
messages.start messages[99]
) )
}) })