From c74d605a29a4b3796e4ee22ea0c25b16445d1586 Mon Sep 17 00:00:00 2001 From: Aman Singh Date: Thu, 10 Oct 2024 11:25:44 +0530 Subject: [PATCH] Added tests --- codegens/curl/test/unit/convert.test.js | 44 +++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/codegens/curl/test/unit/convert.test.js b/codegens/curl/test/unit/convert.test.js index ae2111acc..d3c4c5061 100644 --- a/codegens/curl/test/unit/convert.test.js +++ b/codegens/curl/test/unit/convert.test.js @@ -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({