1 | "use strict"; |
||
2 | |||
3 | /* eslint-disable no-unused-vars */ |
||
4 | |||
5 | 1 | const chai = require('chai'); |
|
6 | 1 | const chaiHttp = require('chai-http'); |
|
7 | 1 | const server = require('../../app'); |
|
8 | 1 | let should = chai.should(); |
|
9 | |||
10 | 1 | chai.use(chaiHttp); |
|
11 | |||
12 | /* global describe */ |
||
13 | /* global it */ |
||
14 | |||
15 | 1 | describe("test all routes", () => { |
|
16 | 1 | describe('/GET index', () => { |
|
17 | 1 | it('it should return object', (done) => { |
|
18 | 1 | chai.request(server) |
|
19 | .get('/') |
||
20 | .end((err, res) => { |
||
21 | 1 | res.should.have.status(200); |
|
22 | 1 | res.should.be.json; |
|
0 ignored issues
–
show
introduced
by
![]() |
|||
23 | 1 | done(); |
|
24 | }); |
||
25 | }); |
||
26 | }); |
||
27 | |||
28 | 1 | describe('/GET post', () => { |
|
29 | 1 | it('it should return post information from Stackoverflow', (done) => { |
|
30 | 1 | chai.request(server) |
|
31 | .get('/posts/47810715') |
||
32 | .end((err, res) => { |
||
33 | 1 | res.should.have.status(200); |
|
34 | 1 | res.should.be.json; |
|
0 ignored issues
–
show
|
|||
35 | 1 | let items = res.body.json.items; |
|
36 | |||
37 | 1 | items[0].title.should.equal("login template accepting every input"); |
|
38 | 1 | items[0].link.should.equal("https://stackoverflow.com/q/47810715"); |
|
39 | 1 | done(); |
|
40 | }); |
||
41 | }); |
||
42 | }); |
||
43 | |||
44 | 1 | describe('/GET Error', () => { |
|
45 | 1 | it('should return error', (done) => { |
|
46 | 1 | chai.request(server) |
|
47 | .get("/munge") |
||
48 | .end((err, res) => { |
||
49 | 1 | res.should.have.status(200); |
|
50 | 1 | res.header["content-type"].should.equal("application/json; charset=utf-8"); |
|
51 | 1 | res.body.should.be.a("object"); |
|
52 | 1 | done(); |
|
53 | }); |
||
54 | }); |
||
55 | }); |
||
56 | }); |
||
57 |