mirror of
https://github.com/oceanprotocol/market.git
synced 2024-11-15 01:34:57 +01:00
29 lines
787 B
TypeScript
29 lines
787 B
TypeScript
import { createMocks } from 'node-mocks-http'
|
|
import apiRoute from '../../../api/file'
|
|
|
|
describe('/api/file', () => {
|
|
test('responds 405 to GET', async () => {
|
|
const { req, res } = createMocks()
|
|
apiRoute(req, res)
|
|
expect(res._getStatusCode()).toBe(405)
|
|
})
|
|
|
|
test('responds 200 to POST', async () => {
|
|
const { req, res } = createMocks({ method: 'POST' })
|
|
apiRoute(req, res)
|
|
expect(res._getStatusCode()).toBe(200)
|
|
})
|
|
|
|
test('responds correctly to POST and url passed in body', async () => {
|
|
const { req, res } = createMocks({
|
|
method: 'POST',
|
|
body: {
|
|
url: 'https://oceanprotocol.com/tech-whitepaper.pdf'
|
|
}
|
|
})
|
|
apiRoute(req, res)
|
|
expect(res._getStatusCode()).toBe(200)
|
|
expect(res._getData()).toBeDefined()
|
|
})
|
|
})
|