From 7a8518d7ca32c5a33195319d6578cbd910b35f0c Mon Sep 17 00:00:00 2001 From: oscnord <6131004+oscnord@users.noreply.github.com> Date: Thu, 1 Feb 2024 16:09:21 +0100 Subject: [PATCH] fix: add tests for tracking endpoint depending on VAST version --- test/routes.spec.js | 51 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/test/routes.spec.js b/test/routes.spec.js index 2d1321a..17c8653 100644 --- a/test/routes.spec.js +++ b/test/routes.spec.js @@ -370,7 +370,7 @@ describe(" MY ROUTES", () => { }); }); // test 6 - describe("GET->SESSIONS/:sessionId/tracking", () => { + describe("GET->SESSIONS/:sessionId/tracking VAST v4.0", () => { let reply; before((done) => { const queryParams = "?adId=mockAd1&progress=100"; @@ -405,6 +405,38 @@ describe(" MY ROUTES", () => { }); }); + describe("GET->SESSIONS/:sessionId/tracking VAST v2.0/v3.0", () => { + let reply; + before((done) => { + const queryParams = "?adID=mockAd1&progress=100"; + chai + .request(SERVER_URL) + .get("/api/v1/sessions/" + SID + "/tracking" + queryParams) + .end((err, res) => { + if (err) { + done(err); + } + reply = res; + done(); + }); + }); + it("should have status 200", () => { + reply.should.have.status(200); + }); + it("should send an object", () => { + reply.body.should.be.a("object"); + }); + it("should be content-type: application/json ", () => { + reply.should.have.header( + "content-type", + "application/json; charset=utf-8" + ); + }); + + it("should return a confirmation message", () => { + reply.body.should.matchPattern({message: _.isString}); + }); + }); describe("GET->SESSIONS/DONT_EXIST/tracking", () => { it("should 404 when sessionID is unknown", (done) => { const queryParams = "?adId=mockAd1&progress=100"; @@ -422,6 +454,23 @@ describe(" MY ROUTES", () => { }); }); }); + describe("GET->SESSIONS/:sessionId/tracking wrong adId param", () => { + it("should 400 when adId/adID param is set to adid", (done) => { + const queryParams = "?adid=mockAd1&progress=100"; + chai + .request(SERVER_URL) + .get("/api/v1/sessions/" + SID + "/tracking" + queryParams) + .end((err, res) => { + if (err) { + done(err); + } + res.should.have.status(400); + res.body.should.be.a("object"); + res.body.should.matchPattern({ message: _.isString }); + done(); + }); + }); + }); // test 7 describe("GET->SESSIONS/:sessionId/events", () => {