Skip to content
This repository has been archived by the owner on Oct 27, 2020. It is now read-only.

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kremalicious committed May 4, 2019
1 parent 30d6679 commit 9bdfca4
Show file tree
Hide file tree
Showing 68 changed files with 3,151 additions and 3,550 deletions.
31 changes: 31 additions & 0 deletions client/__mocks__/user-mock.ts
@@ -0,0 +1,31 @@
const userMock = {
isLogged: false,
isLoading: false,
isWeb3: false,
isNile: false,
account: '',
web3: {},
ocean: {},
balance: { eth: 0, ocn: 0 },
network: '',
requestFromFaucet: jest.fn(),
unlockAccounts: jest.fn(),
message: ''
}

const userMockConnected = {
isLogged: true,
isLoading: false,
isWeb3: true,
isNile: true,
account: '0xxxxxx',
web3: {},
ocean: {},
balance: { eth: 0, ocn: 0 },
network: '',
requestFromFaucet: jest.fn(),
unlockAccounts: jest.fn(),
message: ''
}

export { userMock, userMockConnected }
108 changes: 62 additions & 46 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 25 additions & 18 deletions client/package.json
Expand Up @@ -6,29 +6,29 @@
"scripts": {
"start": "react-scripts start",
"build": "react-scripts --max_old_space_size=4096 build",
"test": "react-scripts test --coverage",
"test:watch": "react-scripts test --coverage --watch",
"test": "react-scripts test --coverage --watchAll=false",
"test:watch": "react-scripts test --coverage",
"eject": "react-scripts eject",
"coverage": "cat coverage/lcov.info | codacy-coverage --token 8801f827fe1144ffa85cd7da94f2bbf7"
},
"dependencies": {
"@oceanprotocol/art": "^2.2.0",
"@oceanprotocol/squid": "^0.5.7",
"@oceanprotocol/squid": "^0.5.8",
"@oceanprotocol/typographies": "^0.1.0",
"classnames": "^2.2.6",
"ethereum-blockies": "MyEtherWallet/blockies",
"filesize": "^4.1.2",
"history": "^4.9.0",
"is-url": "^1.2.4",
"moment": "^2.24.0",
"query-string": "^6.4.2",
"query-string": "^6.5.0",
"react": "^16.8.6",
"react-datepicker": "^2.3.0",
"react-datepicker": "^2.5.0",
"react-dom": "^16.8.6",
"react-dotdotdot": "^1.2.3",
"react-dotdotdot": "^1.3.0",
"react-ga": "^2.5.7",
"react-helmet": "^5.2.0",
"react-markdown": "^4.0.6",
"react-helmet": "^5.2.1",
"react-markdown": "^4.0.8",
"react-moment": "^0.9.2",
"react-paginate": "^6.3.0",
"react-popper": "^1.3.3",
Expand All @@ -38,24 +38,25 @@
"web3": "1.0.0-beta.37"
},
"devDependencies": {
"@react-mock/state": "^0.1.8",
"@types/classnames": "^2.2.7",
"@types/filesize": "^4.1.0",
"@types/is-url": "^1.2.28",
"@types/jest": "^24.0.11",
"@types/react": "^16.8.13",
"@types/react-datepicker": "^2.2.1",
"@types/react-dom": "^16.8.3",
"@types/jest": "^24.0.12",
"@types/react": "^16.8.15",
"@types/react-datepicker": "^2.3.0",
"@types/react-dom": "^16.8.4",
"@types/react-dotdotdot": "^1.2.0",
"@types/react-helmet": "^5.0.8",
"@types/react-paginate": "^6.2.1",
"@types/react-router-dom": "^4.3.1",
"@types/react-transition-group": "^2.8.0",
"@types/react-router-dom": "^4.3.2",
"@types/react-transition-group": "^2.9.1",
"@types/web3": "^1.0.18",
"jest-dom": "^3.1.3",
"jest-dom": "^3.1.4",
"node-sass": "^4.12.0",
"react-scripts": "^3.0.0",
"react-testing-library": "^6.1.2",
"typescript": "^3.4.3"
"react-testing-library": "^7.0.0",
"typescript": "^3.4.5"
},
"repository": {
"type": "git",
Expand All @@ -66,5 +67,11 @@
"not dead",
"not ie <= 11",
"not op_mini all"
]
],
"jest": {
"collectCoverageFrom": [
"src/**/*.{ts,tsx}",
"!src/serviceWorker.ts"
]
}
}
15 changes: 15 additions & 0 deletions client/src/App.test.tsx
@@ -1,10 +1,25 @@
import React from 'react'
import { render } from 'react-testing-library'
import App from './App'
import { User } from './context'
import { userMock } from '../__mocks__/user-mock'

describe('App', () => {
it('should be able to run tests', () => {
expect(1 + 2).toEqual(3)
})

it('renders without crashing', () => {
const { container } = render(<App />)
expect(container.firstChild).toBeInTheDocument()
})

it('renders loading state', () => {
const { container } = render(
<User.Provider value={{ ...userMock, isLoading: true }}>
<App />
</User.Provider>
)
expect(container.querySelector('.spinner')).toBeInTheDocument()
})
})

0 comments on commit 9bdfca4

Please sign in to comment.