1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-11-15 01:34:57 +01:00
market/tests/unit/api/file.test.tsx

29 lines
787 B
TypeScript
Raw Normal View History

2020-05-07 08:03:30 +02:00
import { createMocks } from 'node-mocks-http'
2020-06-30 14:19:27 +02:00
import apiRoute from '../../../api/file'
2020-05-07 08:03:30 +02:00
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()
})
})