From af2f3617f8f4dbce965b88970cb62e3beed44e48 Mon Sep 17 00:00:00 2001 From: aelassas Date: Sun, 17 Nov 2024 23:10:17 +0100 Subject: [PATCH] Update car.test.ts --- api/tests/car.test.ts | 72 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/api/tests/car.test.ts b/api/tests/car.test.ts index 1854ca7c5..6288cfc13 100644 --- a/api/tests/car.test.ts +++ b/api/tests/car.test.ts @@ -464,6 +464,43 @@ describe('POST /api/cars/:page/:size', () => { expect(res.statusCode).toBe(200) expect(res.body[0].resultData.length).toBeGreaterThan(0) + payload.rating = undefined + payload.ranges = undefined + payload.multimedia = undefined + payload.fuelPolicy = undefined + payload.carSpecs!.aircon = undefined + payload.carSpecs!.moreThanFourDoors = undefined + payload.carSpecs!.moreThanFiveSeats = undefined + payload.seats = -1 + res = await request(app) + .post(`/api/cars/${testHelper.PAGE}/${testHelper.SIZE}`) + .set(env.X_ACCESS_TOKEN, token) + .send(payload) + expect(res.statusCode).toBe(200) + expect(res.body[0].resultData.length).toBeGreaterThan(0) + payload.rating = 4 + payload.ranges = [ + bookcarsTypes.CarRange.Mini, + bookcarsTypes.CarRange.Midi, + bookcarsTypes.CarRange.Maxi, + bookcarsTypes.CarRange.Scooter, + ] + payload.multimedia = [bookcarsTypes.CarMultimedia.AndroidAuto] + payload.fuelPolicy = [bookcarsTypes.FuelPolicy.LikeForLike] + + payload.seats = undefined + payload.carSpecs = undefined + res = await request(app) + .post(`/api/cars/${testHelper.PAGE}/${testHelper.SIZE}`) + .set(env.X_ACCESS_TOKEN, token) + .send(payload) + expect(res.statusCode).toBe(200) + expect(res.body[0].resultData.length).toBeGreaterThan(0) + payload.carSpecs = {} + payload.carSpecs!.aircon = true + payload.carSpecs!.moreThanFourDoors = true + payload.carSpecs!.moreThanFiveSeats = true + payload.seats = 5 res = await request(app) .post(`/api/cars/${testHelper.PAGE}/${testHelper.SIZE}`) @@ -608,6 +645,41 @@ describe('POST /api/frontend-cars/:page/:size', () => { expect(res.statusCode).toBe(200) expect(res.body[0].resultData.length).toBeGreaterThan(0) + payload.rating = undefined + payload.ranges = undefined + payload.multimedia = undefined + payload.fuelPolicy = undefined + payload.carSpecs!.aircon = undefined + payload.carSpecs!.moreThanFourDoors = undefined + payload.carSpecs!.moreThanFiveSeats = undefined + payload.seats = -1 + res = await request(app) + .post(`/api/frontend-cars/${testHelper.PAGE}/${testHelper.SIZE}`) + .send(payload) + expect(res.statusCode).toBe(200) + expect(res.body[0].resultData.length).toBeGreaterThan(0) + payload.rating = 4 + payload.ranges = [ + bookcarsTypes.CarRange.Mini, + bookcarsTypes.CarRange.Midi, + bookcarsTypes.CarRange.Maxi, + bookcarsTypes.CarRange.Scooter, + ] + payload.multimedia = [bookcarsTypes.CarMultimedia.AndroidAuto] + payload.fuelPolicy = [bookcarsTypes.FuelPolicy.LikeForLike] + + payload.seats = undefined + payload.carSpecs = undefined + res = await request(app) + .post(`/api/frontend-cars/${testHelper.PAGE}/${testHelper.SIZE}`) + .send(payload) + expect(res.statusCode).toBe(200) + expect(res.body[0].resultData.length).toBeGreaterThan(0) + payload.carSpecs = {} + payload.carSpecs.aircon = true + payload.carSpecs.moreThanFourDoors = true + payload.carSpecs.moreThanFiveSeats = true + payload.seats = 5 res = await request(app) .post(`/api/frontend-cars/${testHelper.PAGE}/${testHelper.SIZE}`)