Created
January 13, 2016 14:48
-
-
Save bendozy/aee258299c188050ae1a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('cohorts index method test', function() { | |
var req = httpMocks.createRequest(); | |
var res = httpMocks.createResponse(); | |
cohortController.index(req, res); | |
it('should display all cohorts in the database', function(done) { | |
var data = JSON.parse(res._getData()); | |
data.length.should.equal(3); | |
res.statusCode.should.equal(200); | |
done(); | |
}); | |
var hiddenReq = httpMocks.createRequest({ | |
query: { | |
hidden: true | |
} | |
}); | |
var hiddenRes = httpMocks.createResponse(); | |
cohortController.index(hiddenReq, hiddenRes); | |
it('should display all cohorts where hidden field value is true', function(done) { | |
var data = JSON.parse(hiddenRes._getData()); | |
data.length.should.equal(2); | |
hiddenRes.statusCode.should.equal(200); | |
done(); | |
}); | |
var invalidReq = httpMocks.createRequest({ | |
query: { | |
hidden: 1 | |
} | |
}); | |
var invalidRes = httpMocks.createResponse(); | |
cohortController.index(invalidReq, invalidRes); | |
it('should return 500 status for invalid query parameter', function(done) { | |
invalidRes.statusCode.should.equal(500); | |
done(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment