added test with jasmine
parent
3a0849efeb
commit
8929d7d41a
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
@ -0,0 +1,42 @@
|
||||
import app from "../index"
|
||||
import image from "../routes/api/image"
|
||||
import supertest from "supertest"
|
||||
|
||||
const request = supertest(app);
|
||||
|
||||
// Endpoint testing
|
||||
describe('Test endpoint responses', () => {
|
||||
it('Get the api endpoint', async () => {
|
||||
const response = await request.get('/api/image?filename=fjord');
|
||||
expect(response.status).toBe(200);
|
||||
})
|
||||
it('Throw an error if the image name is incorrect', async () => {
|
||||
const response = await request.get('/api/image?filename=test');
|
||||
expect(response.status).toBe(404);
|
||||
})
|
||||
it('Working if we only have a filename in the url', async () => {
|
||||
const response = await request.get('/api/image?filename=encenadaport');
|
||||
expect(response.status).toBe(200);
|
||||
})
|
||||
})
|
||||
|
||||
// Image resize test
|
||||
|
||||
describe('Test of the image endpoint with resize', () => {
|
||||
it('Resize working with filename and width parameter', async () => {
|
||||
const response = await request.get('/api/image?filename=encenadaport&height=200');
|
||||
expect(response.status).toBe(200);
|
||||
})
|
||||
it('Resize working with filename and height parameter', async () => {
|
||||
const response = await request.get('/api/image?filename=encenadaport&width=200');
|
||||
expect(response.status).toBe(200);
|
||||
})
|
||||
it('Resize working with filename and width, height parameter', async () => {
|
||||
const response = await request.get('/api/image?filename=encenadaport&height=200');
|
||||
expect(response.status).toBe(200);
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue