Skip to content

Commit c74d605

Browse files
Aman SinghAman Singh
authored andcommitted
Added tests
1 parent 393eefd commit c74d605

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

codegens/curl/test/unit/convert.test.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,50 @@ describe('curl convert function', function () {
289289
});
290290
});
291291

292+
it('should return snippet with JSON body in single line if multiline option is false', function () {
293+
request = new Request({
294+
'method': 'POST',
295+
'header': [],
296+
'body': {
297+
'mode': 'raw',
298+
'raw': '{\n "name": "John",\n "type": "names",\n "id": "123sdaw"\n}',
299+
'options': {
300+
'raw': {
301+
'language': 'json'
302+
}
303+
}
304+
},
305+
'url': {
306+
'raw': 'https://postman-echo.com/post',
307+
'protocol': 'https',
308+
'host': [
309+
'postman-echo',
310+
'com'
311+
],
312+
'path': [
313+
'post'
314+
]
315+
}
316+
});
317+
options = {
318+
multiLine: false,
319+
longFormat: false,
320+
lineContinuationCharacter: '\\',
321+
quoteType: 'single',
322+
requestTimeoutInSeconds: 0,
323+
followRedirect: true,
324+
followOriginalHttpMethod: false
325+
};
326+
327+
convert(request, options, function (error, snippet) {
328+
if (error) {
329+
expect.fail(null, null, error);
330+
}
331+
expect(snippet).to.be.a('string');
332+
expect(snippet).to.contain('-d \'{"name":"John","type":"names","id":"123sdaw"}\'');
333+
});
334+
});
335+
292336
it('should return snippet with backslash(\\) character as line continuation ' +
293337
'character for multiline code generation', function () {
294338
request = new Request({

0 commit comments

Comments
 (0)