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
2020-05-07 09:03:30 +03:00

29 lines
797 B
TypeScript

import { createMocks } from 'node-mocks-http'
import apiRoute from '../../../src/pages/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()
})
})