@@ -263,6 +263,46 @@ describe('nodejs-request convert function', function () {
263
263
} ) ;
264
264
} ) ;
265
265
266
+ it ( 'should return snippet with proper semicolon placed where required' , function ( ) {
267
+ // testing for the below snippet
268
+ /*
269
+ var request = require('request');
270
+ var fs = require('fs');
271
+ var options = {
272
+ 'method': 'GET',
273
+ 'url': 'https://postman-echo.com/headers',
274
+ 'headers': {
275
+ 'my-sample-header': 'Lorem ipsum dolor sit amet',
276
+ 'not-disabled-header': 'ENABLED'
277
+ }
278
+ };
279
+ request(options, function (error, response) {
280
+ if (error) throw new Error(error);
281
+ console.log(response.body);
282
+ }); */
283
+ request = new sdk . Request ( mainCollection . item [ 0 ] . request ) ;
284
+ options = { } ;
285
+ convert ( request , options , function ( error , snippet ) {
286
+ if ( error ) {
287
+ expect . fail ( null , null , error ) ;
288
+ }
289
+ console . log ( snippet ) ;
290
+ expect ( snippet ) . to . be . a ( 'string' ) ;
291
+ var snippetArray = snippet . split ( '\n' ) ;
292
+ snippetArray . forEach ( function ( line , index ) {
293
+ if ( line . charAt ( line . length - 2 ) === ')' ) {
294
+ expect ( line . charAt ( line . length - 1 ) ) . to . equal ( ';' ) ;
295
+ }
296
+ expect ( line . charAt ( line . length - 1 ) ) . to . not . equal ( ')' ) ;
297
+ // check for the closing curly bracket of options object
298
+ if ( line . startsWith ( 'request' ) ) {
299
+ var previousLine = snippetArray [ index - 1 ] ;
300
+ expect ( previousLine . charAt ( previousLine . length - 1 ) ) . to . equal ( ';' ) ;
301
+ }
302
+ } ) ;
303
+ } ) ;
304
+ } ) ;
305
+
266
306
describe ( 'getOptions function' , function ( ) {
267
307
268
308
it ( 'should return an array of specific options' , function ( ) {
0 commit comments