Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- it('it should return all the teams', done => {
- /*
- Here we'll use the Sinon mocking library to have the response mocked with our
- JSON payoad fixture file that we provide to our consumers for them to test aginst
- so that we are both testing with the same structure.
- */
- chai.request(app)
- .get('/v1/teams')
- .end((err, res) => {
- if (err) done(err)
- /*
- * Fail fzst if the basic structure and response code aren't correct.
- */
- expect(res).to.haveOwnProperty('status')
- expect(res).to.haveOwnProperty('body')
- expect(res.status).to.equal(200)
- expect(res.body).to.be.an('array')
- expect(res.body.length).to.be.greaterThan(0)
- /*
- * Check for the REQUIRED properties. Optional properties may also be there,
- * but we don't test for them in the general case, only when they matter.
- */
- expect(res.body[0]).to.haveOwnProperty('id')
- expect(res.body[0]).to.haveOwnProperty('teamId')
- expect(res.body[0]).to.haveOwnProperty('teamName')
- expect(res.body[0]).to.haveOwnProperty('scoreEntries')
- expect(res.body[0].scoreEntries.length).to.be.greaterThan(0)
- done()
- })
- )
- .catch(err => {
- done(err)
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement