From 750c743aaa0f80a68d0264a612cb9d08ca0bbf44 Mon Sep 17 00:00:00 2001 From: Miguel Fernandez Date: Sun, 27 Dec 2020 03:00:22 +0100 Subject: [PATCH] =?UTF-8?q?a=C3=B1ado=20los=20test=20para=20la=20API=20#2?= =?UTF-8?q?=20#6=20#9=20#10=20#27=20#38=20#43?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/app.test.js | 130 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 test/app.test.js diff --git a/test/app.test.js b/test/app.test.js new file mode 100644 index 0000000..4ea1117 --- /dev/null +++ b/test/app.test.js @@ -0,0 +1,130 @@ +const request = require('supertest'); +const app = require('../src/app.js') + +describe('GET /', () => { + it('should get OK status', (done) => { + request(app) + .get('/') + .expect('Content-Type', /json/) + .expect(200, done); + }) +}) + +//HU:02 ---> AƱadir una prenda nueva +describe('POST /item', () => { + it('should add a new item', (done) => { + request(app) + .post('/item') + .send(item) + .expect(201,done); + }) +}) + +//HU:01 ---> Mostrar informaciĆ³n de una prenda +describe('GET /item', () => { + it('should get every item', (done) => { + request(app) + .get('/item') + .expect(200, done); + }) +}) + + +//HU:04 ---> Modificar una prenda +describe('PUT /item', () => { + it('should update an item', (done) => { + request(app) + .put('/item') + .expect('Content-Type', /json/) + .send(newItem) + .expect(200, done) + }) +}) + +//HU:07 ---> Como usuario quiero consultar el tipo de prenda que hay de una determinada marca +describe('GET /item/:brand', () => { + it('should get every accessory', (done) => { + request(app) + .get('/item/NIKE') + .expect('Content-Type', /json/) + .expect(200, done); + }) +}) + +//HU:05 ---> Consultar un accesorio +describe('GET /accessory', () => { + it('should get every accessory', (done) => { + request(app) + .get('/accessory') + .expect('Content-Type', /json/) + .expect(200, done); + }) +}) + +describe('POST /accessory', () => { + it('should add a new accessory', (done) => { + request(app) + .post('/accessory') + .send(item) + .expect(201,done); + }) +}) + +// +describe('GET /type', () => { + it('should get every existing type', (done) => { + request(app) + .get('/type') + .expect('Content-Type', /json/) + .expect(200, done); + }) +}) + +//HU:08 ---> Como usuario quiero consultar el tipo de prenda disponible de una termporada en concreto + +describe('GET /type/:season', () => { + it('should get every existing type of certain season', (done) => { + request(app) + .get('/type/FALL_WINTER') + .expect('Content-Type', /json/) + .expect(200, done); + }); +}) + + +describe('GET /brand', () => { + it('should get every existing brand', (done) => { + request(app) + .get('/brand') + .expect('Content-Type', /json/) + .expect(200, done); + }) +}) + +//HU:03 ---> Eliminar una prenda +describe('DELETE /item', () => { + it('should delete an item', (done) => { + request(app) + .delete('/item') + .send(item) + .expect(200,done) + }) +}) + +let item = { + "type": "HOODIE", + "size": "S", + "brand": "KAPPA", + "color": "WHITE", + "price": 22, + "season": "FALL_WINTER" +} + +let newItem = { + "type": "JEANS", + "size": "M", + "brand": "NIKE", + "color": "RED", + "price": 25, + "season": "SPRING_SUMMER" +}