Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,26 @@ describe('console parser', () => {
expect(errors[0].offset).toBe(14);
expect(errors[0].text).toBe('Bad string');
});

it('parses requests with an error and a comment before the next request', () => {
const input =
'GET _search\n' +
'{ERROR\n' +
' "query": {\n' +
' "match_all": {}\n' +
' }\n' +
'}\n\n' +
'# This is a comment\n' +
'POST _test_index\n' +
'// Another comment\n';
const { requests, errors } = parser(input) as ConsoleParserResult;
expect(requests.length).toBe(2);
expect(requests[0].startOffset).toBe(0);
expect(requests[0].endOffset).toBe(57);
expect(requests[1].startOffset).toBe(79); // The next request should start after the comment
expect(requests[1].endOffset).toBe(95);
expect(errors.length).toBe(1);
expect(errors[0].offset).toBe(14);
expect(errors[0].text).toBe('Bad string');
});
});