Writting test for profile

This commit is contained in:
Jamie Hewitt 2022-08-25 17:37:06 +03:00
parent 4a61b881fc
commit e9c754d26a
5 changed files with 61 additions and 1489 deletions

View File

@ -62,6 +62,7 @@ export default async function EnsProfileApi(
) { ) {
try { try {
const accountId = String(request.query.address) const accountId = String(request.query.address)
console.log('accountId', accountId)
const profile = await getEnsProfile(accountId) const profile = await getEnsProfile(accountId)
response.setHeader('Cache-Control', 'max-age=0, s-maxage=86400') response.setHeader('Cache-Control', 'max-age=0, s-maxage=86400')

1523
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -16,7 +16,9 @@
"ethers": "^5.7.0" "ethers": "^5.7.0"
}, },
"devDependencies": { "devDependencies": {
"@types/chai": "^4.3.3",
"@types/mocha": "^9.1.1", "@types/mocha": "^9.1.1",
"@types/test-listen": "^1.1.0",
"@typescript-eslint/eslint-plugin": "^5.28.0", "@typescript-eslint/eslint-plugin": "^5.28.0",
"@typescript-eslint/parser": "^5.29.0", "@typescript-eslint/parser": "^5.29.0",
"@vercel/node": "^2.5.8", "@vercel/node": "^2.5.8",

View File

@ -1,5 +1,6 @@
import addressApi from '../api/address' import addressApi from '../api/address'
import nameApi from '../api/name' import nameApi from '../api/name'
import profileApi from '../api/profile'
import { createServer } from 'vercel-node-server' import { createServer } from 'vercel-node-server'
import listen from 'test-listen' import listen from 'test-listen'
// import express from 'express' // import express from 'express'
@ -14,7 +15,7 @@ const name = 'jellymcjellyfish.eth'
const accountId = '0x99840Df5Cb42faBE0Feb8811Aaa4BC99cA6C84e0' const accountId = '0x99840Df5Cb42faBE0Feb8811Aaa4BC99cA6C84e0'
describe('Testing ENS proxy API endpoints', function () { describe('Testing ENS proxy API endpoints', function () {
this.timeout(10000) this.timeout(20000)
it('Requesting address should return the expected response', async () => { it('Requesting address should return the expected response', async () => {
server = createServer(addressApi) server = createServer(addressApi)
@ -36,6 +37,24 @@ describe('Testing ENS proxy API endpoints', function () {
}) })
assert(response.data.name === name) assert(response.data.name === name)
}) })
it('Requesting user profile should return the expected response', async () => {
server = createServer(profileApi)
url = await listen(server)
const response = await axios.get(url, {
params: {
address: accountId
}
})
console.log('profile', response.data.profile)
assert(response.data.profile.name === name)
assert(
response.data.profile.avatar ===
'https://metadata.ens.domains/mainnet/avatar/jellymcjellyfish.eth'
)
assert(response.data.profile.links[0].value === 'https://oceanprotocol.com')
assert(response.data.profile.links[2].value === 'oceanprotocol')
assert(response.data.profile.links[3].value === 'oceanprotocol')
})
}) })
after(() => { after(() => {

View File

@ -6,7 +6,8 @@
"noEmit": true, "noEmit": true,
"module": "esnext", "module": "esnext",
"moduleResolution": "node", "moduleResolution": "node",
"isolatedModules": true "isolatedModules": true,
"allowSyntheticDefaultImports": true
}, },
"exclude": ["node_modules"], "exclude": ["node_modules"],
"include": ["**/*.ts", "**/*.tsx"] "include": ["**/*.ts", "**/*.tsx"]