Total Complexity | 3 |
Complexity/F | 1 |
Lines of Code | 59 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { buildJsonResponse } from '../response'; |
||
2 | |||
3 | const TestCases = [ |
||
4 | { |
||
5 | description: |
||
6 | 'The statusCode should be a valid http status code, and a number', |
||
7 | params: { |
||
8 | statusCode: '200', |
||
9 | body: {}, |
||
10 | }, |
||
11 | specification: {}, |
||
12 | expectedResult: 'statusCode must have a valid http status code', |
||
13 | }, |
||
14 | { |
||
15 | description: 'The statusCode should be a valid http status code', |
||
16 | params: { |
||
17 | statusCode: 123, |
||
18 | body: {}, |
||
19 | }, |
||
20 | specification: {}, |
||
21 | expectedResult: 'statusCode must have a valid http status code', |
||
22 | }, |
||
23 | { |
||
24 | description: 'The headers should be a valid array or object', |
||
25 | params: { |
||
26 | statusCode: 200, |
||
27 | headers: 'invalid headers', |
||
28 | body: {}, |
||
29 | }, |
||
30 | specification: {}, |
||
31 | expectedResult: 'headers must have a valid object', |
||
32 | }, |
||
33 | { |
||
34 | description: 'The body should be a valid array or object', |
||
35 | params: { |
||
36 | statusCode: 200, |
||
37 | body: 'example', |
||
38 | }, |
||
39 | specification: {}, |
||
40 | expectedResult: 'body must have a valid object', |
||
41 | }, |
||
42 | { |
||
43 | description: 'The specification should be a valid object', |
||
44 | params: {}, |
||
45 | specification: 'invalid specification', |
||
46 | expectedResult: 'specification must have a valid object', |
||
47 | }, |
||
48 | ]; |
||
49 | |||
50 | describe.each(TestCases)( |
||
|
|||
51 | 'Response entity errors', |
||
52 | ({ description, params, specification, expectedResult }) => { |
||
53 | it(description, () => { |
||
54 | expect(() => buildJsonResponse(params, specification)).toThrow( |
||
55 | expectedResult |
||
56 | ); |
||
57 | }); |
||
58 | } |
||
59 | ); |
||
60 |
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.