Skip to content

Commit

Permalink
added unit-tests for the error handler of the chunked-download-routes
Browse files Browse the repository at this point in the history
  • Loading branch information
supernomad committed Jun 21, 2015
1 parent 311306b commit 2ec0c06
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions test/routes/chunked-download-routes-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,56 @@ describe("chunked-upload-routes.js", function() {
should.exist(routes.error.handler);
routes.error.handler.should.be.a.Function;
});

it('should handle any custom errors', function(done) {
routes.error.handler(errorModels.DownloadMissing(), null, {
status: function(status) {
should.exist(status);
status.should.be.a.Number;
status.should.equal(404);
},
json: function(data) {
should.exist(data);
data.should.be.a.Object;
should.exist(data.Error);
should.exist(data.Message);
routes.error.handler(errorModels.ValidationError("error"), null, {
status: function(status) {
should.exist(status);
status.should.be.a.Number;
status.should.equal(400);
},
json: function(data) {
should.exist(data);
data.should.be.a.Object;
should.exist(data.Error);
should.exist(data.Message);
routes.error.handler(errorModels.ServerError(), null, {
status: function(status) {
should.exist(status);
status.should.be.a.Number;
status.should.equal(500);
},
json: function(data) {
should.exist(data);
data.should.be.a.Object;
should.exist(data.Error);
should.exist(data.Message);
done();
}
}, function(){ false.should.be.true; });
}
}, function(){ false.should.be.true; });
}
}, function(){ false.should.be.true; });
});


it('should call next if it is not a custom error', function(done) {
routes.error.handler(new Error("Generic error"), null, null, function() {
true.should.be.true;
done();
});
});
});
});

0 comments on commit 2ec0c06

Please sign in to comment.