Guest User

Untitled

a guest
Mar 29th, 2018
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. describe('When a person is logged in', () => {
  2. let fakePerson;
  3. let fakeCompany;
  4. let cookie;
  5. let agent = request.agent(server);
  6.  
  7. beforeEach(async () => {
  8. fakePerson = await query.insert('people', {
  9. username: 'username',
  10. password: 'password',
  11. email: 'username@example.com',
  12. activation_completed_at: new Date()
  13. });
  14.  
  15. return agent
  16. .post('/login')
  17. .send({
  18. username: fakePerson.username,
  19. password: fakePerson.password
  20. })
  21. .expect(200)
  22. .then(res => {
  23. cookie = res
  24. .headers['set-cookie'][0]
  25. .split(',')
  26. .map(item => item.split(';')[0])
  27. .join(';')
  28. expect(res.status).toEqual(200)
  29. });
  30. });
  31.  
  32.  
  33. it ('They can view the add company page', () => {
  34. agent
  35. .get('/companies/new')
  36. // We set the request cookie to the block-scoped variable "cookie" we
  37. // re-assign in the beforeEach() block
  38. .set('Cookie', cookie)
  39. .then(res => {
  40. expect(res.status).toEqual(200)
  41. });
  42. });
  43. });
Add Comment
Please, Sign In to add comment