mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
fix
This commit is contained in:
parent
071072c26b
commit
f21a4c8780
@ -1,8 +1,17 @@
|
|||||||
import web3Mock from './web3'
|
import web3Mock from './web3'
|
||||||
import React, { useContext, createContext } from 'react'
|
import React from 'react'
|
||||||
import { Web3ProviderValue } from '@oceanprotocol/react'
|
import { Web3ProviderValue } from '@oceanprotocol/react'
|
||||||
|
|
||||||
const valueMock = {
|
export const context = React.createContext<Web3ProviderValue | undefined>({
|
||||||
|
web3: web3Mock,
|
||||||
|
ethProviderStatus: -1,
|
||||||
|
account: '0x0000',
|
||||||
|
balance: '',
|
||||||
|
chainId: 1,
|
||||||
|
web3Connect: {} as any,
|
||||||
|
enable: () => null as any
|
||||||
|
})
|
||||||
|
export default {
|
||||||
web3: web3Mock,
|
web3: web3Mock,
|
||||||
ethProviderStatus: -1,
|
ethProviderStatus: -1,
|
||||||
account: '0x0000',
|
account: '0x0000',
|
||||||
@ -11,20 +20,3 @@ const valueMock = {
|
|||||||
web3Connect: {} as any,
|
web3Connect: {} as any,
|
||||||
enable: () => null as any
|
enable: () => null as any
|
||||||
}
|
}
|
||||||
|
|
||||||
const Web3ContextMock = React.createContext<Web3ProviderValue>(valueMock)
|
|
||||||
|
|
||||||
// TODO: this will have to be updated to web3modal
|
|
||||||
function Web3ProviderMock({ children }: { children: any }): any {
|
|
||||||
return (
|
|
||||||
<Web3ContextMock.Provider value={valueMock}>
|
|
||||||
{children}
|
|
||||||
</Web3ContextMock.Provider>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper hook to access the provider values
|
|
||||||
const useWeb3 = (): Web3ProviderValue => useContext(Web3ContextMock)
|
|
||||||
|
|
||||||
export { Web3ProviderMock, useWeb3 }
|
|
||||||
export default Web3ProviderMock
|
|
||||||
|
@ -3,11 +3,8 @@ import { render } from '@testing-library/react'
|
|||||||
import AssetDetails, { getMetadata } from '../../../src/pages/asset/[did]'
|
import AssetDetails, { getMetadata } from '../../../src/pages/asset/[did]'
|
||||||
import ddo from '../__fixtures__/ddo'
|
import ddo from '../__fixtures__/ddo'
|
||||||
import { findServiceByType } from '../../../src/utils'
|
import { findServiceByType } from '../../../src/utils'
|
||||||
|
import web3ProviderMock, { context } from '../__mocks__/web3provider'
|
||||||
import { MetaDataDexFreight } from '../../../src/@types/MetaData'
|
import { MetaDataDexFreight } from '../../../src/@types/MetaData'
|
||||||
import { OceanProvider, Config } from '@oceanprotocol/react'
|
|
||||||
import { config } from '../../../src/config/ocean'
|
|
||||||
import { Web3ProviderMock } from '../__mocks__/web3provider'
|
|
||||||
|
|
||||||
const { attributes } = findServiceByType(ddo, 'metadata')
|
const { attributes } = findServiceByType(ddo, 'metadata')
|
||||||
|
|
||||||
@ -16,15 +13,13 @@ jest.mock('web3')
|
|||||||
describe('AssetDetails', () => {
|
describe('AssetDetails', () => {
|
||||||
it('renders without crashing', () => {
|
it('renders without crashing', () => {
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
<Web3ProviderMock>
|
<context.Provider value={web3ProviderMock}>
|
||||||
<OceanProvider config={config as Config}>
|
|
||||||
<AssetDetails
|
<AssetDetails
|
||||||
ddo={JSON.stringify(ddo) as any}
|
ddo={JSON.stringify(ddo) as any}
|
||||||
attributes={attributes as MetaDataDexFreight}
|
attributes={attributes as MetaDataDexFreight}
|
||||||
title="Hello"
|
title="Hello"
|
||||||
/>
|
/>
|
||||||
</OceanProvider>
|
</context.Provider>
|
||||||
</Web3ProviderMock>
|
|
||||||
)
|
)
|
||||||
expect(container.firstChild).toBeInTheDocument()
|
expect(container.firstChild).toBeInTheDocument()
|
||||||
})
|
})
|
||||||
|
@ -1,19 +1,14 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { render } from '@testing-library/react'
|
import { render } from '@testing-library/react'
|
||||||
import Publish from '../../../src/pages/publish'
|
import Publish from '../../../src/pages/publish'
|
||||||
|
import web3ProviderMock, { context } from '../__mocks__/web3provider'
|
||||||
import { OceanProvider, Config } from '@oceanprotocol/react'
|
|
||||||
import { config } from '../../../src/config/ocean'
|
|
||||||
import { Web3ProviderMock } from '../__mocks__/web3provider'
|
|
||||||
|
|
||||||
describe('Home', () => {
|
describe('Home', () => {
|
||||||
it('renders without crashing', () => {
|
it('renders without crashing', () => {
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
<Web3ProviderMock>
|
<context.Provider value={web3ProviderMock}>
|
||||||
<OceanProvider config={config as Config}>
|
|
||||||
<Publish />
|
<Publish />
|
||||||
</OceanProvider>
|
</context.Provider>
|
||||||
</Web3ProviderMock>
|
|
||||||
)
|
)
|
||||||
expect(container.firstChild).toBeInTheDocument()
|
expect(container.firstChild).toBeInTheDocument()
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user