-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
51 lines (39 loc) · 1.35 KB
/
test.js
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
var chai = require('chai');
var expect = require('chai').expect;
var fs = require('fs');
chai.use(require('chai-http'));
var app = require('./server.js');
describe('API endpoint /', () => {
// GET - root
it('root should return status 200', () => {
return chai.request(app)
.get('/')
.then((res) => {
expect(res).to.have.status(200);
});
});
});
describe('API endpoint /api/phonenumbers/parse/text', () => {
// GET - number
it('should return [\'+1 416-491-5050\']', () => {
return chai.request(app)
.get('/api/phonenumbers/parse/text/Seneca%20Phone%20Number%3A%20416-491-5050')
.then((res) => {
expect(res).to.have.status(200);
expect(res.body).to.be.an('array').that.include('+1 416-491-5050');
});
});
});
describe('API endpoint /api/phonenumbers/parse/file', () => {
// POST - file
it('should return [\'+1 647-550-8230\', \'+1 647-550-8231\', \'+1 647-550-8232\']', () => {
return chai.request(app)
.post('/api/phonenumbers/parse/file')
.set('Content-Type', 'text/plain')
.attach('file', fs.readFileSync('./phonenumbers.txt'), 'phonenumbers.txt')
.then((res) => {
expect(res).to.have.status(200);
expect(res.body).to.be.an('array').that.include('+1 647-550-8233', '+1 647-550-8234', '+1 647-550-8235');
});
})
});