-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthentication.js
More file actions
51 lines (50 loc) · 1.49 KB
/
Copy pathauthentication.js
File metadata and controls
51 lines (50 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const chai = require('chai');
const request = require('supertest');
const app = require('../src/config/server/server').default;
const user = require('./fixtures/user.json');
chai.should();
/**
* storing globals to access them in API requests
*/
global.token = '';
/**
* Authentication tests
*/
describe('Authentication', () => {
it('sign up', (done) => {
request(app)
.post('/auth/signup')
.send(user)
.expect('Content-type', /json/)
.expect((res) => {
res.body.status.should.equal(200);
res.body.logged.should.equal(true);
res.body.message.should.be.a('string');
global.token = res.body.token;
})
.end(done)
});
it('sign up user with existing email', (done) => {
request(app)
.post('/auth/signup')
.send(user)
.expect('Content-type', /json/)
.expect((res) => {
res.body.status.should.equal(400);
})
.end(done);
});
it('login to app', (done) => {
request(app)
.post('/auth/login')
.send(user)
.expect('Content-type', /json/)
.expect((res) => {
res.body.status.should.equal(200);
res.body.logged.should.equal(true);
res.body.message.should.be.a('string');
global.token = res.body.token;
})
.end(done);
});
});