Compare commits
3 Commits
3a0849efeb
...
30775e7b41
Author | SHA1 | Date |
---|---|---|
Vic | 30775e7b41 | 2 years ago |
Vic | ac382953b1 | 2 years ago |
Vic | 8929d7d41a | 2 years ago |
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
@ -1,20 +1,16 @@
|
||||
import express from 'express';
|
||||
import routes from './routes/routesIndex'
|
||||
import express from 'express'
|
||||
import routes from './routes/index'
|
||||
|
||||
const app = express();
|
||||
const port = 3000;
|
||||
|
||||
|
||||
// app.get('/api', (req, res) => {
|
||||
// res.send('welcome to api');
|
||||
// })
|
||||
|
||||
// get routes
|
||||
app.use('/api', routes)
|
||||
|
||||
// start Express server
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`server started at http://localhost:${port}`);
|
||||
})
|
||||
|
||||
|
||||
export default app;
|
@ -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