mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
test & storybook fixes
This commit is contained in:
parent
88f9c47b8c
commit
b5356e6c42
@ -1,9 +1,7 @@
|
|||||||
import React, { ReactElement } from 'react'
|
import React, { ReactElement } from 'react'
|
||||||
import Compute from './Compute'
|
import Compute from './Compute'
|
||||||
import ddo from '../../../../tests/unit/__fixtures__/ddo'
|
import ddo from '../../../../tests/unit/__fixtures__/ddo'
|
||||||
import web3Mock from '../../../../tests/unit/__mocks__/web3'
|
import { DDO } from '@oceanprotocol/lib'
|
||||||
import squidMock from '../../../../tests/unit/__mocks__/@oceanprotocol/lib'
|
|
||||||
import { context } from '../../../../tests/unit/__mocks__/web3provider'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'Organisms/Compute',
|
title: 'Organisms/Compute',
|
||||||
@ -15,12 +13,5 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const Default = (): ReactElement => (
|
export const Default = (): ReactElement => (
|
||||||
<context.Provider value={web3Mock}>
|
<Compute ddo={ddo as DDO} isBalanceSufficient />
|
||||||
<Compute
|
|
||||||
did={ddo.id}
|
|
||||||
ocean={squidMock.ocean as any}
|
|
||||||
metadata={ddo.findServiceByType('metadata').attributes as any}
|
|
||||||
balance="1000000"
|
|
||||||
/>
|
|
||||||
</context.Provider>
|
|
||||||
)
|
)
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import React, { ReactElement } from 'react'
|
import React, { ReactElement } from 'react'
|
||||||
import Consume from './Consume'
|
import Consume from './Consume'
|
||||||
import ddo from '../../../../tests/unit/__fixtures__/ddo'
|
import ddo from '../../../../tests/unit/__fixtures__/ddo'
|
||||||
import web3Mock from '../../../../tests/unit/__mocks__/web3'
|
import { DDO } from '@oceanprotocol/lib'
|
||||||
import { context } from '../../../../tests/unit/__mocks__/web3provider'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'Organisms/Consume',
|
title: 'Organisms/Consume',
|
||||||
@ -14,10 +13,9 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const PricedAsset = (): ReactElement => (
|
export const PricedAsset = (): ReactElement => (
|
||||||
<context.Provider value={web3Mock}>
|
|
||||||
<Consume
|
<Consume
|
||||||
did={ddo.id}
|
ddo={ddo as DDO}
|
||||||
metadata={ddo.findServiceByType('metadata').attributes as any}
|
isBalanceSufficient
|
||||||
|
file={new DDO(ddo).findServiceByType('metadata').attributes.main.files[0]}
|
||||||
/>
|
/>
|
||||||
</context.Provider>
|
|
||||||
)
|
)
|
||||||
|
@ -44,7 +44,7 @@ export default function PageTemplateAssetDetails({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
init()
|
init()
|
||||||
}, [did])
|
}, [did, config.metadataStoreUri])
|
||||||
|
|
||||||
return did && metadata ? (
|
return did && metadata ? (
|
||||||
<Layout title={title} uri={uri}>
|
<Layout title={title} uri={uri}>
|
||||||
|
@ -11,7 +11,7 @@ const metadataStore = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const squidMock = {
|
const libMock = {
|
||||||
MetadataStore: () => metadataStore,
|
MetadataStore: () => metadataStore,
|
||||||
DDO: () => ddo,
|
DDO: () => ddo,
|
||||||
ocean: {
|
ocean: {
|
||||||
@ -42,26 +42,6 @@ const squidMock = {
|
|||||||
consume: () => null as any,
|
consume: () => null as any,
|
||||||
getFreeWhiteList: () => Promise.resolve([])
|
getFreeWhiteList: () => Promise.resolve([])
|
||||||
},
|
},
|
||||||
keeper: {
|
|
||||||
conditions: {
|
|
||||||
accessSecretStoreCondition: {
|
|
||||||
getGrantedDidByConsumer: () => {
|
|
||||||
return {
|
|
||||||
find: Promise.resolve(
|
|
||||||
'did:op:e6fda48e8d814d5d9655645aac3c046cc87528dbc1a9449799e579d7b83d1360'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
agreementStoreManager: {
|
|
||||||
getAgreement: (agreementId: string) =>
|
|
||||||
Promise.resolve({
|
|
||||||
did:
|
|
||||||
'did:op:e6fda48e8d814d5d9655645aac3c046cc87528dbc1a9449799e579d7b83d1360'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
versions: {
|
versions: {
|
||||||
get: () =>
|
get: () =>
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
@ -92,4 +72,4 @@ const squidMock = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default squidMock
|
export default libMock
|
||||||
|
@ -1,15 +1,7 @@
|
|||||||
import React, { ReactElement } from 'react'
|
import React, { ReactElement } from 'react'
|
||||||
import libMock from './lib'
|
import libMock from './lib'
|
||||||
import web3ProviderMock from '../web3provider'
|
|
||||||
|
|
||||||
const reactMock = {
|
const reactMock = {
|
||||||
Web3Provider: function Component({
|
|
||||||
children
|
|
||||||
}: {
|
|
||||||
children: ReactElement
|
|
||||||
}): ReactElement {
|
|
||||||
return <div>{children}</div>
|
|
||||||
},
|
|
||||||
OceanProvider: function Component({
|
OceanProvider: function Component({
|
||||||
children
|
children
|
||||||
}: {
|
}: {
|
||||||
@ -19,14 +11,13 @@ const reactMock = {
|
|||||||
},
|
},
|
||||||
useOcean: () => {
|
useOcean: () => {
|
||||||
return {
|
return {
|
||||||
ocean: libMock.ocean
|
ocean: libMock.ocean,
|
||||||
}
|
config: {},
|
||||||
},
|
web3: null,
|
||||||
useWeb3: () => {
|
web3Modal: null,
|
||||||
return {
|
web3Provider: null,
|
||||||
...web3ProviderMock,
|
accountId: '0x0000000011111111aaaaaaaabbbbbbbb22222222',
|
||||||
account: '0x0000000011111111aaaaaaaabbbbbbbb22222222',
|
balance: '0.12'
|
||||||
ethProviderStatus: 1
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
useConsume: () => {
|
useConsume: () => {
|
||||||
|
@ -19,6 +19,7 @@ export const globalMock = {
|
|||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
jest.mock('web3')
|
jest.mock('web3')
|
||||||
|
jest.mock('@oceanprotocol/lib')
|
||||||
jest.mock('@oceanprotocol/react')
|
jest.mock('@oceanprotocol/react')
|
||||||
|
|
||||||
// useOcean.mockImplementation(() => mockReact.useOcean())
|
// useOcean.mockImplementation(() => mockReact.useOcean())
|
||||||
|
Loading…
Reference in New Issue
Block a user