Skip to content

Commit 303e5e6

Browse files
author
Olle Johannesson
committed
Move test for client/Response.parse in order not to confuse code coverage
1 parent e467ac1 commit 303e5e6

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

spec/amadeus/client/response.test.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,27 @@ describe('Response', () => {
4747
expect(response.data).toEqual('b');
4848
});
4949

50-
it('should not parse if not json', () => {
51-
response.contentType = 'plain/text';
50+
it('should handle badly formed json', () => {
51+
response.addChunk('{ "a" : ');
5252
response.parse();
5353
expect(response.parsed).toBeFalsy();
5454
expect(response.result).toBeNull();
5555
expect(response.data).toBeNull();
5656
});
5757

58-
it('should not parse if status code is 204', () => {
59-
response.contentType = 'plain/text';
60-
response.statusCode = 204;
58+
it('should not parse if not json', () => {
59+
response.headers['content-type'] = 'plain/text';
6160
response.parse();
6261
expect(response.parsed).toBeFalsy();
6362
expect(response.result).toBeNull();
6463
expect(response.data).toBeNull();
6564
});
6665

67-
it('should handle badly formed json', () => {
68-
response.addChunk('{ "a" : ');
69-
response.parse();
66+
it('should not parse if status code is 204', () => {
67+
response.contentType = 'plain/text';
68+
response.statusCode = 204;
69+
const parsingReturnValue = response.parse();
70+
expect(parsingReturnValue).toBeUndefined();
7071
expect(response.parsed).toBeFalsy();
7172
expect(response.result).toBeNull();
7273
expect(response.data).toBeNull();

0 commit comments

Comments
 (0)