Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe('When a person is logged in', () => {
- let fakePerson;
- let fakeCompany;
- let cookie;
- let agent = request.agent(server);
- beforeEach(async () => {
- fakePerson = await query.insert('people', {
- username: 'username',
- password: 'password',
- email: 'username@example.com',
- activation_completed_at: new Date()
- });
- return agent
- .post('/login')
- .send({
- username: fakePerson.username,
- password: fakePerson.password
- })
- .expect(200)
- .then(res => {
- cookie = res
- .headers['set-cookie'][0]
- .split(',')
- .map(item => item.split(';')[0])
- .join(';')
- expect(res.status).toEqual(200)
- });
- });
- it ('They can view the add company page', () => {
- agent
- .get('/companies/new')
- // We set the request cookie to the block-scoped variable "cookie" we
- // re-assign in the beforeEach() block
- .set('Cookie', cookie)
- .then(res => {
- expect(res.status).toEqual(200)
- });
- });
- });
Add Comment
Please, Sign In to add comment