Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. it('it should return all the teams', done => {
  2. /*
  3. Here we'll use the Sinon mocking library to have the response mocked with our
  4. JSON payoad fixture file that we provide to our consumers for them to test aginst
  5. so that we are both testing with the same structure.
  6. */
  7. chai.request(app)
  8. .get('/v1/teams')
  9. .end((err, res) => {
  10. if (err) done(err)
  11.  
  12. /*
  13. * Fail fzst if the basic structure and response code aren't correct.
  14. */
  15. expect(res).to.haveOwnProperty('status')
  16. expect(res).to.haveOwnProperty('body')
  17. expect(res.status).to.equal(200)
  18. expect(res.body).to.be.an('array')
  19. expect(res.body.length).to.be.greaterThan(0)
  20.  
  21. /*
  22. * Check for the REQUIRED properties. Optional properties may also be there,
  23. * but we don't test for them in the general case, only when they matter.
  24. */
  25. expect(res.body[0]).to.haveOwnProperty('id')
  26. expect(res.body[0]).to.haveOwnProperty('teamId')
  27. expect(res.body[0]).to.haveOwnProperty('teamName')
  28. expect(res.body[0]).to.haveOwnProperty('scoreEntries')
  29. expect(res.body[0].scoreEntries.length).to.be.greaterThan(0)
  30.  
  31. done()
  32. })
  33. )
  34. .catch(err => {
  35. done(err)
  36. })
  37. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement