You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
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);
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|