ens-proxy/test/api.test.ts
2022-08-25 16:57:26 +03:00

44 lines
1.1 KiB
TypeScript

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()
})