mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
test temp fix
This commit is contained in:
parent
c7efdb2001
commit
41fcb2f4c3
@ -155,10 +155,9 @@ const PublishForm: React.FC<PublishFormProps> = () => {
|
|||||||
)
|
)
|
||||||
services = [computeService]
|
services = [computeService]
|
||||||
}
|
}
|
||||||
console.log(metadata as MetaData)
|
|
||||||
try {
|
try {
|
||||||
const asset = await ocean.assets.create(
|
const asset = await ocean.assets.create(
|
||||||
metadata as MetaData,
|
(metadata as unknown) as MetaData,
|
||||||
account,
|
account,
|
||||||
services
|
services
|
||||||
)
|
)
|
||||||
|
@ -28,7 +28,7 @@ export const NoWeb3Browser = () => {
|
|||||||
export const NoAccountConnected = () => {
|
export const NoAccountConnected = () => {
|
||||||
const mock = {
|
const mock = {
|
||||||
...web3ProviderMock,
|
...web3ProviderMock,
|
||||||
ethProviderStatus: InjectedProviderStatus.NOT_CONNECTED,
|
ethProviderStatus: 0,
|
||||||
account: ''
|
account: ''
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
@ -41,7 +41,7 @@ export const NoAccountConnected = () => {
|
|||||||
export const NotConnectedToPacific = () => {
|
export const NotConnectedToPacific = () => {
|
||||||
const mock = {
|
const mock = {
|
||||||
...web3ProviderMock,
|
...web3ProviderMock,
|
||||||
ethProviderStatus: InjectedProviderStatus.CONNECTED,
|
ethProviderStatus: 1,
|
||||||
account: '0x0000000011111111aaaaaaaabbbbbbbb22222222',
|
account: '0x0000000011111111aaaaaaaabbbbbbbb22222222',
|
||||||
balance: '11223.748267896',
|
balance: '11223.748267896',
|
||||||
web3: {
|
web3: {
|
||||||
@ -63,7 +63,7 @@ export const NotConnectedToPacific = () => {
|
|||||||
export const ErrorConnectingToOcean = () => {
|
export const ErrorConnectingToOcean = () => {
|
||||||
const mock = {
|
const mock = {
|
||||||
...web3ProviderMock,
|
...web3ProviderMock,
|
||||||
ethProviderStatus: InjectedProviderStatus.CONNECTED,
|
ethProviderStatus: 1,
|
||||||
account: '0x0000000011111111aaaaaaaabbbbbbbb22222222',
|
account: '0x0000000011111111aaaaaaaabbbbbbbb22222222',
|
||||||
balance: '11223.748267896',
|
balance: '11223.748267896',
|
||||||
web3: {
|
web3: {
|
||||||
@ -84,7 +84,7 @@ export const ErrorConnectingToOcean = () => {
|
|||||||
export const ErrorInssuficientBalance = () => {
|
export const ErrorInssuficientBalance = () => {
|
||||||
const mock = {
|
const mock = {
|
||||||
...web3ProviderMock,
|
...web3ProviderMock,
|
||||||
ethProviderStatus: InjectedProviderStatus.CONNECTED,
|
ethProviderStatus: 1,
|
||||||
account: '0x0000000011111111aaaaaaaabbbbbbbb22222222',
|
account: '0x0000000011111111aaaaaaaabbbbbbbb22222222',
|
||||||
balance: '11223.748267896'
|
balance: '11223.748267896'
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ export const ErrorInssuficientBalance = () => {
|
|||||||
export const ConnectedToOcean = () => {
|
export const ConnectedToOcean = () => {
|
||||||
const mock = {
|
const mock = {
|
||||||
...web3ProviderMock,
|
...web3ProviderMock,
|
||||||
ethProviderStatus: InjectedProviderStatus.CONNECTED,
|
ethProviderStatus: 1,
|
||||||
account: '0x0000000011111111aaaaaaaabbbbbbbb22222222',
|
account: '0x0000000011111111aaaaaaaabbbbbbbb22222222',
|
||||||
balance: '11223.748267896'
|
balance: '11223.748267896'
|
||||||
}
|
}
|
||||||
|
@ -22,16 +22,11 @@ export default function Web3Feedback({
|
|||||||
}) {
|
}) {
|
||||||
const { ethProviderStatus } = useWeb3()
|
const { ethProviderStatus } = useWeb3()
|
||||||
const { status, balanceInOcean } = useOcean()
|
const { status, balanceInOcean } = useOcean()
|
||||||
const isEthProviderAbsent =
|
const isEthProviderAbsent = ethProviderStatus === -1
|
||||||
ethProviderStatus === InjectedProviderStatus.NOT_AVAILABLE
|
const isEthProviderDisconnected = ethProviderStatus === 0
|
||||||
const isEthProviderDisconnected =
|
const isOceanDisconnected = status === 0
|
||||||
ethProviderStatus === InjectedProviderStatus.NOT_CONNECTED
|
const isOceanConnectionError = status === -1
|
||||||
const isOceanDisconnected = status === OceanConnectionStatus.NOT_CONNECTED
|
const hasSuccess = ethProviderStatus === 1 && status === 1
|
||||||
const isOceanConnectionError =
|
|
||||||
status === OceanConnectionStatus.OCEAN_CONNECTION_ERROR
|
|
||||||
const hasSuccess =
|
|
||||||
ethProviderStatus === InjectedProviderStatus.CONNECTED &&
|
|
||||||
status === OceanConnectionStatus.CONNECTED
|
|
||||||
|
|
||||||
const state = isEthProviderAbsent
|
const state = isEthProviderAbsent
|
||||||
? 'error'
|
? 'error'
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React, { useEffect, useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import { DDO, Aquarius, Logger, Curation } from '@oceanprotocol/squid'
|
import { DDO } from '@oceanprotocol/squid'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import Layout from '../../../Layout'
|
import Layout from '../../../Layout'
|
||||||
import { MetaDataMarket } from '../../../@types/MetaData'
|
import { MetaDataMarket } from '../../../@types/MetaData'
|
||||||
|
@ -3,23 +3,53 @@ 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 { MetaDataMarket } from '../../../src/@types/MetaData'
|
import { MetaDataMarket } from '../../../src/@types/MetaData'
|
||||||
|
import oceanMock from '../__mocks__/ocean-mock'
|
||||||
|
import web3ProviderMock from '../__mocks__/web3'
|
||||||
const { attributes } = findServiceByType(ddo, 'metadata')
|
const { attributes } = findServiceByType(ddo, 'metadata')
|
||||||
|
// import { useOcean } from '@oceanprotocol/react'
|
||||||
|
|
||||||
jest.mock('web3')
|
jest.mock('web3')
|
||||||
|
jest.mock('@oceanprotocol/react')
|
||||||
|
|
||||||
|
// eslint-disable-next-line
|
||||||
|
jest.mock('@oceanprotocol/react', () => ({
|
||||||
|
useOcean: () => {
|
||||||
|
return {
|
||||||
|
ocean: oceanMock
|
||||||
|
}
|
||||||
|
},
|
||||||
|
useWeb3: () => {
|
||||||
|
return {
|
||||||
|
web3: web3ProviderMock,
|
||||||
|
account: '0x0000000011111111aaaaaaaabbbbbbbb22222222',
|
||||||
|
ethProviderStatus: 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
useConsume: () => {
|
||||||
|
return {
|
||||||
|
consume: () => null as any,
|
||||||
|
consumeStepText: '',
|
||||||
|
isLoading: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
useMetadata: () => {
|
||||||
|
return {
|
||||||
|
getCuration: () => {
|
||||||
|
return Promise.resolve({ rating: 0, numVotes: 0 })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
describe('AssetDetails', () => {
|
describe('AssetDetails', () => {
|
||||||
it('renders without crashing', () => {
|
it('renders without crashing', () => {
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
<context.Provider value={web3ProviderMock}>
|
<AssetDetails
|
||||||
<AssetDetails
|
ddo={JSON.stringify(ddo) as any}
|
||||||
ddo={JSON.stringify(ddo) as any}
|
attributes={attributes as MetaDataMarket}
|
||||||
attributes={attributes as MetaDataMarket}
|
title="Hello"
|
||||||
title="Hello"
|
/>
|
||||||
/>
|
|
||||||
</context.Provider>
|
|
||||||
)
|
)
|
||||||
expect(container.firstChild).toBeInTheDocument()
|
expect(container.firstChild).toBeInTheDocument()
|
||||||
})
|
})
|
||||||
@ -40,8 +70,8 @@ describe('getMetadata()', () => {
|
|||||||
|
|
||||||
it('Found', async () => {
|
it('Found', async () => {
|
||||||
const response = await getMetadata(
|
const response = await getMetadata(
|
||||||
'did:op:ee8532e6e338484cb439043125270bd1caf45a7a25a64e71a55b3a18f647d7da'
|
'did:op:8898adb69e334755a568738ce3f6c03760f9eb5a4f344c688e483a04cb0855d6'
|
||||||
)
|
)
|
||||||
expect(response.title).toBe('Invoices test')
|
expect(response.title).toBe('compute1')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -2,14 +2,41 @@ 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 web3ProviderMock, { context } from '../__mocks__/web3provider'
|
||||||
|
import oceanMock from '../__mocks__/ocean-mock'
|
||||||
|
|
||||||
|
// eslint-disable-next-line
|
||||||
|
jest.mock('@oceanprotocol/react', () => ({
|
||||||
|
useOcean: () => {
|
||||||
|
return {
|
||||||
|
ocean: oceanMock
|
||||||
|
}
|
||||||
|
},
|
||||||
|
useWeb3: () => {
|
||||||
|
return {
|
||||||
|
web3: web3ProviderMock,
|
||||||
|
account: '0x0000000011111111aaaaaaaabbbbbbbb22222222',
|
||||||
|
ethProviderStatus: 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
useConsume: () => {
|
||||||
|
return {
|
||||||
|
consume: () => null as any,
|
||||||
|
consumeStepText: '',
|
||||||
|
isLoading: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
useMetadata: () => {
|
||||||
|
return {
|
||||||
|
getCuration: () => {
|
||||||
|
return Promise.resolve({ rating: 0, numVotes: 0 })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
describe('Home', () => {
|
describe('Home', () => {
|
||||||
it('renders without crashing', () => {
|
it('renders without crashing', () => {
|
||||||
const { container } = render(
|
const { container } = render(<Publish />)
|
||||||
<context.Provider value={web3ProviderMock}>
|
|
||||||
<Publish />
|
|
||||||
</context.Provider>
|
|
||||||
)
|
|
||||||
expect(container.firstChild).toBeInTheDocument()
|
expect(container.firstChild).toBeInTheDocument()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1,10 +1,81 @@
|
|||||||
import initStoryshots from '@storybook/addon-storyshots'
|
import initStoryshots from '@storybook/addon-storyshots'
|
||||||
import { render, wait } from '@testing-library/react'
|
import { render, wait } from '@testing-library/react'
|
||||||
|
import oceanMock from './__mocks__/ocean-mock'
|
||||||
|
import web3ProviderMock from './__mocks__/web3'
|
||||||
|
|
||||||
|
// eslint-disable-next-line
|
||||||
|
jest.mock('@oceanprotocol/react', () => ({
|
||||||
|
useOcean: () => {
|
||||||
|
return {
|
||||||
|
ocean: oceanMock
|
||||||
|
}
|
||||||
|
},
|
||||||
|
useWeb3: () => {
|
||||||
|
return {
|
||||||
|
web3: web3ProviderMock,
|
||||||
|
account: '0x0000000011111111aaaaaaaabbbbbbbb22222222',
|
||||||
|
ethProviderStatus: 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
useConsume: () => {
|
||||||
|
return {
|
||||||
|
consume: () => null as any,
|
||||||
|
consumeStepText: '',
|
||||||
|
isLoading: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
useMetadata: () => {
|
||||||
|
return {
|
||||||
|
getCuration: () => {
|
||||||
|
return Promise.resolve({ rating: 0, numVotes: 0 })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}))
|
||||||
// jest.mock('@oceanprotocol/squid')
|
// jest.mock('@oceanprotocol/squid')
|
||||||
|
|
||||||
// Stories are render-tested with @testing-library/react,
|
// Stories are render-tested with @testing-library/react,
|
||||||
// overwriting default snapshot testing behavior
|
// overwriting default snapshot testing behavior
|
||||||
|
|
||||||
|
// eslint-disable-next-line
|
||||||
|
jest.mock('@oceanprotocol/react', () => ({
|
||||||
|
useOcean: () => {
|
||||||
|
return {
|
||||||
|
ocean: oceanMock
|
||||||
|
}
|
||||||
|
},
|
||||||
|
useWeb3: () => {
|
||||||
|
return {
|
||||||
|
web3: web3ProviderMock,
|
||||||
|
account: '0x0000000011111111aaaaaaaabbbbbbbb22222222',
|
||||||
|
ethProviderStatus: 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
useConsume: () => {
|
||||||
|
return {
|
||||||
|
consume: () => null as any,
|
||||||
|
consumeStepText: '',
|
||||||
|
isLoading: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
useCompute: () => {
|
||||||
|
return {
|
||||||
|
compute: () => null as any,
|
||||||
|
isLoading: false,
|
||||||
|
computeStepText: 0,
|
||||||
|
computeError: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
useMetadata: () => {
|
||||||
|
return {
|
||||||
|
getCuration: () => {
|
||||||
|
return Promise.resolve({ rating: 0, numVotes: 0 })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computeOptions: ['', '']
|
||||||
|
}))
|
||||||
|
|
||||||
initStoryshots({
|
initStoryshots({
|
||||||
asyncJest: true,
|
asyncJest: true,
|
||||||
test: async ({ story, done }) => {
|
test: async ({ story, done }) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user