mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
fix test
This commit is contained in:
parent
093c6c184d
commit
b03074ecee
14
README.md
14
README.md
@ -79,10 +79,20 @@ To run all tests, including all linting tests:
|
|||||||
npm test
|
npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
For local development, you can start the test runner in interactive watch mode:
|
For local development, you can start the test runners for client & server in a watch mode.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm test:watch
|
npm run test:watch
|
||||||
|
```
|
||||||
|
|
||||||
|
This will work for daily development but it misses the full interactivity of the test runner. If you need that, you will need to run them in individual terminal sessions:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd client/
|
||||||
|
npm run test:watch
|
||||||
|
|
||||||
|
cd server/
|
||||||
|
npm run test:watch
|
||||||
```
|
```
|
||||||
|
|
||||||
## ✨ Code Style
|
## ✨ Code Style
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import ReactDOM from 'react-dom'
|
import { render } from 'react-testing-library'
|
||||||
import App from './App'
|
import App from './App'
|
||||||
|
|
||||||
it('renders without crashing', () => {
|
describe('App', () => {
|
||||||
const div = document.createElement('div')
|
it('renders without crashing', () => {
|
||||||
ReactDOM.render(<App />, div)
|
const { container } = render(<App />)
|
||||||
ReactDOM.unmountComponentAtNode(div)
|
expect(container.firstChild).toBeInTheDocument()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
33
client/src/components/atoms/CategoryImage.test.tsx
Normal file
33
client/src/components/atoms/CategoryImage.test.tsx
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { render } from 'react-testing-library'
|
||||||
|
import slugify from 'slugify'
|
||||||
|
import CategoryImage from './CategoryImage'
|
||||||
|
import formPublish from '../../data/form-publish.json'
|
||||||
|
|
||||||
|
describe('CategoryImage', () => {
|
||||||
|
it('renders fallback image', () => {
|
||||||
|
const { container, getByTestId } = render(
|
||||||
|
<CategoryImage data-testid="image" category={''} />
|
||||||
|
)
|
||||||
|
expect(container.firstChild).toBeInTheDocument()
|
||||||
|
expect(getByTestId('image').style.backgroundImage).toMatch(
|
||||||
|
/jellyfish-back/
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('renders all the category images', () => {
|
||||||
|
const { options } = formPublish.steps[1].fields
|
||||||
|
? formPublish.steps[1].fields.categories
|
||||||
|
: []
|
||||||
|
|
||||||
|
options.map((category: string) => {
|
||||||
|
const { getByTestId } = render(
|
||||||
|
<CategoryImage data-testid="image" category={category} />
|
||||||
|
)
|
||||||
|
expect(getByTestId('image')).toBeInTheDocument()
|
||||||
|
// expect(getByTestId('image').style.backgroundImage).toMatch(
|
||||||
|
// slugify(category, { lower: true })
|
||||||
|
// )
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
@ -148,6 +148,7 @@ export default class CategoryImage extends PureComponent<{ category: string }> {
|
|||||||
style={{
|
style={{
|
||||||
backgroundImage: `url(${image})`
|
backgroundImage: `url(${image})`
|
||||||
}}
|
}}
|
||||||
|
{...this.props}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ export default class Input extends PureComponent<InputProps, InputState> {
|
|||||||
value: date
|
value: date
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.props.onChange!(event as any)
|
this.props.onChange!(event as any) // eslint-disable-line @typescript-eslint/no-non-null-assertion
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputComponent = () => {
|
public InputComponent = () => {
|
||||||
|
@ -17,17 +17,17 @@ export default class Pagination extends PureComponent<
|
|||||||
PaginationState
|
PaginationState
|
||||||
> {
|
> {
|
||||||
public state = { smallViewport: true }
|
public state = { smallViewport: true }
|
||||||
private mq = matchMedia && window.matchMedia('(min-width: 600px)')
|
private mq = window.matchMedia && window.matchMedia('(min-width: 600px)')
|
||||||
|
|
||||||
public componentDidMount() {
|
public componentDidMount() {
|
||||||
if (matchMedia) {
|
if (window.matchMedia) {
|
||||||
this.mq.addListener(this.viewportChange)
|
this.mq.addListener(this.viewportChange)
|
||||||
this.viewportChange(this.mq)
|
this.viewportChange(this.mq)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public componentWillUnmount() {
|
public componentWillUnmount() {
|
||||||
if (matchMedia) {
|
if (window.matchMedia) {
|
||||||
this.mq.removeListener(this.viewportChange)
|
this.mq.removeListener(this.viewportChange)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
"start": "concurrently \"cd client && npm start\" \"cd server && npm start\"",
|
"start": "concurrently \"cd client && npm start\" \"cd server && npm start\"",
|
||||||
"build": "./scripts/build.sh",
|
"build": "./scripts/build.sh",
|
||||||
"test": "npm run lint && scripts/test.sh",
|
"test": "npm run lint && scripts/test.sh",
|
||||||
|
"test:watch": "npm run lint && concurrently \"cd client && npm run test:watch\" \"cd server && npm run test:watch\"",
|
||||||
"format:js": "prettier --parser typescript --write '**/*.{js,jsx,ts,tsx}'",
|
"format:js": "prettier --parser typescript --write '**/*.{js,jsx,ts,tsx}'",
|
||||||
"format:css": "prettier-stylelint --ignore-path .gitignore --write --quiet '**/*.{css,scss}'",
|
"format:css": "prettier-stylelint --ignore-path .gitignore --write --quiet '**/*.{css,scss}'",
|
||||||
"format": "npm run format:js && npm run format:css",
|
"format": "npm run format:js && npm run format:css",
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
"serve": "node dist/server.js",
|
"serve": "node dist/server.js",
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"test": "jest --coverage",
|
"test": "jest --coverage",
|
||||||
"test-watch": "npm run test --watchAll"
|
"test:watch": "jest --coverage --watch"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"body-parser": "^1.18.3",
|
"body-parser": "^1.18.3",
|
||||||
|
Loading…
Reference in New Issue
Block a user