mirror of
https://github.com/oceanprotocol/ens-proxy.git
synced 2024-12-02 05:57:34 +01:00
Setting up tests for name and address endpoints
This commit is contained in:
parent
d226949460
commit
4a61b881fc
3845
package-lock.json
generated
3845
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -9,21 +9,28 @@
|
||||
"clean": "rm -rf ./dist",
|
||||
"format": "prettier --ignore-path .gitignore './**/*.{css,yml,js,ts,tsx,json}' --write",
|
||||
"test:format": "npm run format && npm run lint",
|
||||
"test": "ts-mocha -p test/tsconfig.json --exit test/**/*.test.ts",
|
||||
"type-check": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"ethers": "^5.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/mocha": "^9.1.1",
|
||||
"@typescript-eslint/eslint-plugin": "^5.28.0",
|
||||
"@typescript-eslint/parser": "^5.29.0",
|
||||
"@vercel/node": "^2.5.8",
|
||||
"axios": "^0.27.2",
|
||||
"chai": "^4.3.6",
|
||||
"eslint": "^8.18.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"husky": "^7.0.0",
|
||||
"prettier": "^2.7.1",
|
||||
"pretty-quick": "^3.1.3",
|
||||
"typescript": "4.7.3"
|
||||
"test-listen": "^1.1.0",
|
||||
"ts-mocha": "^10.0.0",
|
||||
"typescript": "4.7.3",
|
||||
"vercel-node-server": "^2.2.1"
|
||||
}
|
||||
}
|
||||
|
43
test/api.test.ts
Normal file
43
test/api.test.ts
Normal file
@ -0,0 +1,43 @@
|
||||
import addressApi from '../api/address'
|
||||
import nameApi from '../api/name'
|
||||
import { createServer } from 'vercel-node-server'
|
||||
import listen from 'test-listen'
|
||||
// import express from 'express'
|
||||
// import request from 'supertest'
|
||||
import axios from 'axios'
|
||||
// import type { VercelRequest, VercelResponse } from '@vercel/node'
|
||||
import { assert } from 'chai'
|
||||
|
||||
let server
|
||||
let url: string
|
||||
const name = 'jellymcjellyfish.eth'
|
||||
const accountId = '0x99840Df5Cb42faBE0Feb8811Aaa4BC99cA6C84e0'
|
||||
|
||||
describe('Testing ENS proxy API endpoints', function () {
|
||||
this.timeout(10000)
|
||||
|
||||
it('Requesting address should return the expected response', async () => {
|
||||
server = createServer(addressApi)
|
||||
url = await listen(server)
|
||||
const response = await axios.get(url, {
|
||||
params: {
|
||||
name
|
||||
}
|
||||
})
|
||||
assert(response.data.address === accountId)
|
||||
})
|
||||
it('Requesting ENS name should return the expected response', async () => {
|
||||
server = createServer(nameApi)
|
||||
url = await listen(server)
|
||||
const response = await axios.get(url, {
|
||||
params: {
|
||||
accountId
|
||||
}
|
||||
})
|
||||
assert(response.data.name === name)
|
||||
})
|
||||
})
|
||||
|
||||
after(() => {
|
||||
server.close()
|
||||
})
|
9
test/tsconfig.json
Normal file
9
test/tsconfig.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"resolveJsonModule": true,
|
||||
"lib": ["es6", "es7"],
|
||||
"noUnusedLocals": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user