Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Aman Singh authored and Aman Singh committed Oct 10, 2024
1 parent 393eefd commit c74d605
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions codegens/curl/test/unit/convert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,50 @@ describe('curl convert function', function () {
});
});

it('should return snippet with JSON body in single line if multiline option is false', function () {
request = new Request({
'method': 'POST',
'header': [],
'body': {
'mode': 'raw',
'raw': '{\n "name": "John",\n "type": "names",\n "id": "123sdaw"\n}',
'options': {
'raw': {
'language': 'json'
}
}
},
'url': {
'raw': 'https://postman-echo.com/post',
'protocol': 'https',
'host': [
'postman-echo',
'com'
],
'path': [
'post'
]
}
});
options = {
multiLine: false,
longFormat: false,
lineContinuationCharacter: '\\',
quoteType: 'single',
requestTimeoutInSeconds: 0,
followRedirect: true,
followOriginalHttpMethod: false
};

convert(request, options, function (error, snippet) {
if (error) {
expect.fail(null, null, error);
}
expect(snippet).to.be.a('string');
expect(snippet).to.contain('-d \'{"name":"John","type":"names","id":"123sdaw"}\'');
});
});

it('should return snippet with backslash(\\) character as line continuation ' +
'character for multiline code generation', function () {
request = new Request({
Expand Down

0 comments on commit c74d605

Please sign in to comment.