Skip to content

Commit

Permalink
adding more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonSharratt committed Jan 31, 2020
1 parent 6b1b841 commit 619a7b8
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
52 changes: 50 additions & 2 deletions microservices/requestApi/test/v1/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ describe("Requests", function() {
describe('/GET v1 & v1/requestId', function () {
it('it should get requests', function (done) {
chai.request(server)
.get('/v1?limit=1&page=1&name=testName')
.get('/v1?limit=1&page=1&name=testName&start_date=2000-01-01-01-01-01&end_date=9999-01-01-01-01-01')
.set("Authorization", "Bearer " + jwt)
.end(function (err, res) {
res.should.have.status(200);
Expand Down Expand Up @@ -313,6 +313,18 @@ describe("Requests", function() {
});
});

it('it should fail to save a request', function (done) {
chai.request(server)
.put('/v1/save/1')
.set("Authorization", "Bearer " + jwt)
.send({})
.end(function (err, res) {
res.should.have.status(400);
res.body.should.be.a('object');
res.body.should.have.property('error');
});
});

it('it should save a request', function (done) {
chai.request(server)
.put('/v1/save/' + activeRequestId)
Expand Down Expand Up @@ -364,6 +376,17 @@ describe("Requests", function() {
done();
});
});

it('it should fail to save a request that is in wrong state', function (done) {
chai.request(server)
.put('/v1/save/' + activeRequestId)
.set("Authorization", "Bearer " + jwt)
.end(function (err, res) {
res.should.have.status(400);
res.body.should.be.a('object');
res.body.should.have.property('error');
});
});
});

describe('/PUT /v1/pickup/requestId', function() {
Expand Down Expand Up @@ -406,7 +429,6 @@ describe("Requests", function() {
.set("Authorization", "Bearer " + jwt)
.send({
name: "testName3",
tags: ["test"],
purpose: "purpose",
phoneNumber: "555-555-5555",
subPopulation: "sub-population",
Expand Down Expand Up @@ -483,6 +505,19 @@ describe("Requests", function() {
setTimeout(done, 2000);
});
});

it('it should fail to submit an invalid request', function (done) {
chai.request(server)
.put('/v1/submit/1')
.set("Authorization", "Bearer " + jwt)
.send({})
.end(function (err, res) {
res.should.have.status(400);
res.body.should.be.a('object');
res.body.should.have.property('error');
done();
});
});

it('it should submit a request', function (done) {
chai.request(server)
Expand All @@ -498,6 +533,19 @@ describe("Requests", function() {
});
});

it('it should fail to submit an already submitted request', function (done) {
chai.request(server)
.put('/v1/submit/' + activeRequestId)
.set("Authorization", "Bearer " + jwt)
.send({})
.end(function (err, res) {
res.should.have.status(400);
res.body.should.be.a('object');
res.body.should.have.property('error');
done();
});
});

it('it should pickup a request', function (done) {
chai.request(server)
.put('/v1/pickup/' + activeRequestId)
Expand Down
2 changes: 1 addition & 1 deletion microservices/requestApi/test/v2/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ describe("Requests", function() {
describe('/GET v2 & v2/requestId', function () {
it('it should get requests', function (done) {
chai.request(server)
.get('/v2?limit=1&page=1&state=0')
.get('/v2?limit=101&page=0&state=0&name=*')
.set("Authorization", "Bearer " + jwt)
.end(function (err, res) {
res.should.have.status(200);
Expand Down

0 comments on commit 619a7b8

Please sign in to comment.