Skip to content

Commit

Permalink
fix: add tests for tracking endpoint depending on VAST version
Browse files Browse the repository at this point in the history
  • Loading branch information
oscnord committed Feb 1, 2024
1 parent 0cf8714 commit 7a8518d
Showing 1 changed file with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion test/routes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand All @@ -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", () => {
Expand Down

0 comments on commit 7a8518d

Please sign in to comment.