Total Complexity | 7 |
Complexity/F | 1 |
Lines of Code | 64 |
Function Count | 7 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | const router = require('./../../../src/routes/index'); |
||
2 | |||
3 | describe('Index routes.', () => { |
||
4 | test('GET homepage', (done) => { |
||
5 | const request = { |
||
6 | method: 'GET', |
||
7 | url: '/', |
||
8 | }; |
||
9 | const response = { |
||
10 | redirect: (targetUrl) => { |
||
11 | expect(targetUrl).toMatch(/.+/); |
||
12 | done(); |
||
13 | }, |
||
14 | }; |
||
15 | |||
16 | router.handle(request, response); |
||
17 | }); |
||
18 | |||
19 | test('GET page by streamId', (done) => { |
||
20 | const request = { |
||
21 | method: 'GET', |
||
22 | url: '/testId', |
||
23 | }; |
||
24 | const response = { |
||
25 | render: (tpl, data) => { |
||
26 | expect(tpl).toBe('index'); |
||
27 | expect(typeof data).toBe('object'); |
||
28 | done(); |
||
29 | }, |
||
30 | }; |
||
31 | |||
32 | router.handle(request, response); |
||
33 | }); |
||
34 | |||
35 | test('POST to page by streamId', (done) => { |
||
36 | const request = { |
||
37 | method: 'POST', |
||
38 | url: '/testId', |
||
39 | headers: { |
||
40 | 'content-type': 'application/json', |
||
41 | }, |
||
42 | connection: { |
||
43 | socket: { |
||
44 | remoteAddress: 'testIp', |
||
45 | }, |
||
46 | }, |
||
47 | socket: {}, |
||
48 | body: 'RAW Body.', |
||
49 | }; |
||
50 | const response = { |
||
51 | status: jest.fn(), |
||
|
|||
52 | send: jest.fn(), |
||
53 | }; |
||
54 | global.socket = { |
||
55 | emit: (type, data) => { |
||
56 | expect(type).toBe('log'); |
||
57 | expect(typeof data).toBe('object'); |
||
58 | done(); |
||
59 | }, |
||
60 | }; |
||
61 | |||
62 | router.handle(request, response); |
||
63 | }); |
||
64 | }); |
||
65 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.