diff --git a/client/src/routes/Details/AssetDetails.test.tsx b/client/src/routes/Details/AssetDetails.test.tsx
index 8de750c..61e837e 100644
--- a/client/src/routes/Details/AssetDetails.test.tsx
+++ b/client/src/routes/Details/AssetDetails.test.tsx
@@ -2,7 +2,7 @@ import React from 'react'
import { render } from 'react-testing-library'
import { DDO, MetaData } from '@oceanprotocol/squid'
import { BrowserRouter as Router } from 'react-router-dom'
-import AssetDetails, { datafilesLine } from './AssetDetails'
+import AssetDetails, { renderDatafilesLine } from './AssetDetails'
/* eslint-disable @typescript-eslint/no-explicit-any */
describe('AssetDetails', () => {
@@ -10,7 +10,7 @@ describe('AssetDetails', () => {
const { container } = render(
)
expect(container.firstChild).toBeInTheDocument()
@@ -30,7 +30,7 @@ describe('AssetDetails', () => {
}
} as any) as MetaData
}
- ddo={({} as any) as DDO}
+ ddo={({ proof: { creator: '0xxxxx' } } as any) as DDO}
/>
)
@@ -40,18 +40,18 @@ describe('AssetDetails', () => {
expect(container.firstChild).toHaveTextContent('Category')
})
- it('datafilesLine renders correctly for one file', () => {
+ it('renderDatafilesLine renders correctly for one file', () => {
const files = [
{
index: 0,
url: 'https://hello.com'
}
]
- const { container } = render(datafilesLine(files))
+ const { container } = render(renderDatafilesLine(files))
expect(container.firstChild).toHaveTextContent('1 data file')
})
- it('datafilesLine renders correctly for multiple files', () => {
+ it('renderDatafilesLine renders correctly for multiple files', () => {
const files = [
{
index: 0,
@@ -62,7 +62,7 @@ describe('AssetDetails', () => {
url: 'https://hello2.com'
}
]
- const { container } = render(datafilesLine(files))
+ const { container } = render(renderDatafilesLine(files))
expect(container.firstChild).toHaveTextContent('2 data files')
})
})
diff --git a/client/src/routes/Details/AssetDetails.tsx b/client/src/routes/Details/AssetDetails.tsx
index cd8381c..65bc48a 100644
--- a/client/src/routes/Details/AssetDetails.tsx
+++ b/client/src/routes/Details/AssetDetails.tsx
@@ -13,6 +13,13 @@ import { serviceHost, servicePort, serviceScheme } from '../../config'
const { steps } = require('../../data/form-publish.json') // eslint-disable-line
+export const renderDatafilesLine = (files: any) =>
+ files.length === 1 ? (
+ {files.length} data file
+ ) : (
+ {files.length} data files
+ )
+
interface AssetDetailsProps {
metadata: MetaData
ddo: DDO
@@ -154,13 +161,6 @@ export default class AssetDetails extends PureComponent<
this.setState({ isLoading: false })
}
- private renderDatafilesLine = (files: any) =>
- files.length === 1 ? (
- {files.length} data file
- ) : (
- {files.length} data files
- )
-
private CopyrightHolder = ({ value }: { value: string }) =>
this.state.isEditMode ? (
diff --git a/client/src/routes/Details/AssetFile.test.tsx b/client/src/routes/Details/AssetFile.test.tsx
index 5b135b7..b871f53 100644
--- a/client/src/routes/Details/AssetFile.test.tsx
+++ b/client/src/routes/Details/AssetFile.test.tsx
@@ -35,42 +35,38 @@ const contextConnectedMock = {
ReactGA.initialize('foo', { testMode: true })
describe('AssetFile', () => {
+ const Component =
+
it('renders without crashing', () => {
- const { container } = render()
+ const { container } = render(Component)
expect(container.firstChild).toBeInTheDocument()
})
it('button to be disabled when not connected', () => {
- const { container } = render()
+ const { container } = render(Component)
expect(container.querySelector('button')).toHaveAttribute('disabled')
})
it('button to be enabled when connected', async () => {
const { getByText } = render(
-
+ {Component}
)
const button = getByText('Get file')
expect(button).not.toHaveAttribute('disabled')
-
- fireEvent.click(button)
})
it('renders loading state', async () => {
const { container } = render(
-
-
-
+ {Component}
)
expect(container.querySelector('.spinner')).toBeInTheDocument()
})
it('renders error', async () => {
const { container } = render(
-
-
-
+ {Component}
)
expect(container.querySelector('.error')).toBeInTheDocument()
expect(container.querySelector('.error')).toHaveTextContent(