Initial setup for writting tests

This commit is contained in:
Jamie Hewitt 2022-08-22 11:14:57 +03:00
parent a2ac64afa5
commit c1375f5bff
6 changed files with 1697 additions and 6 deletions

1623
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -18,11 +18,18 @@
"@ensdomains/ensjs": "^2.1.0",
"@oceanprotocol/lib": "^1.1.8",
"@urql/exchange-refocus": "^0.2.5",
"mock-local-storage": "^1.1.23",
"next": "^12.2.5",
"urql": "^2.2.3",
"web3": "^1.7.5"
},
"devDependencies": {
"@babel/core": "^7.18.5",
"@babel/eslint-parser": "^7.18.2",
"@babel/preset-typescript": "^7.16.7",
"@types/express": "^4.17.11",
"@types/mocha": "^9.1.1",
"@types/node": "^18.0.0",
"@types/react": "^18.0.17",
"@typescript-eslint/eslint-plugin": "^5.28.0",
"@typescript-eslint/parser": "^5.29.0",
@ -32,10 +39,12 @@
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.0",
"mocha": "^10.0.0",
"mock-local-storage": "^1.1.23",
"nodemon": "^2.0.16",
"prettier": "^2.7.1",
"pretty-quick": "^3.1.3",
"supertest": "^6.2.3",
"ts-node": "^10.8.1",
"ts-node": "^10.9.1",
"typescript": "4.7.3"
}
}

11
test/.mocharc.json Normal file
View File

@ -0,0 +1,11 @@
{
"require": [
"ts-node/register",
"source-map-support/register",
"mock-local-storage"
],
"full-trace": true,
"bail": true,
"exit": true,
"timeout": "20000"
}

48
test/api.test.ts Normal file
View File

@ -0,0 +1,48 @@
import { expect } from 'chai'
import request from 'supertest'
import name from '../pages/api/name'
describe('Price Request Tests', () => {
it('Starts the server', async () => {
request(name)
.get(
'/ipfs/QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D/ocean-protocol'
)
.expect('Content-Type', /json/)
.expect(200)
})
// it('Gets the current price of OCEAN', async () => {
// const response = await request(app)
// .get(
// '/ipfs/QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D/ocean-protocol'
// )
// .expect('Content-Type', /json/)
// .expect(200)
// expect(response.body.usd).to.be.within(0.1, 100)
// })
// it('Gets the current price of USDT', async () => {
// const response = await request(app)
// .get('/ipfs/QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D/tether')
// .expect('Content-Type', /json/)
// .expect(200)
// expect(response.body.usd).to.be.within(0.9, 1.1)
// })
// it('Gets the historical price of OCEAN', async () => {
// const response = await request(app)
// .get(
// '/ipfs/QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D/ocean-protocol/1620245790'
// )
// .expect('Content-Type', /json/)
// .expect(200)
// expect(response.body.usd).to.equal(1.4499657614470953)
// })
// it('Gets the historical price of Ether', async () => {
// const response = await request(app)
// .get(
// '/ipfs/QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D/ethereum/1550245790'
// )
// .expect('Content-Type', /json/)
// .expect(200)
// expect(response.body.usd).to.equal(153.0565669307744)
// })
})

9
test/tsconfig.json Normal file
View File

@ -0,0 +1,9 @@
{
"compilerOptions": {
"resolveJsonModule": true,
"lib": ["es6", "es7"],
"noUnusedLocals": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
}
}

View File

@ -10,6 +10,7 @@
"incremental": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"