@@ -767,16 +767,15 @@ describe('curl convert function', function () {
767767 } ) ;
768768 } ) ;
769769
770- it ( 'should add --request parameter when options ' +
771- 'followRedirect and followOriginalHttpMethod are true' , function ( ) {
772- const methods = [ 'GET' , 'HEAD' , 'DELETE' , 'PUT' , 'POST' , 'PATCH' ] ,
773- request = new sdk . Request ( {
770+ describe ( 'followRedirect and followOriginalHttpMethod' , function ( ) {
771+ it ( 'should add --request parameter when passed true via options' , function ( ) {
772+ const request = new sdk . Request ( {
774773 'method' : 'POST' ,
775774 'header' : [ ] ,
776775 'body' : {
777776 'mode' : 'graphql' ,
778777 'graphql' : {
779- 'query' : '{\n findScenes(\n filter: {per_page: 0}\n scene_filter: {is_missing: "performers"}){\n count\n scenes {\n id\n title\n path\n }\n }\n}' , // eslint-disable-line
778+ 'query' : '{\n findScenes(\n filter: {per_page: 0}\n scene_filter: {is_missing: "performers"}){\n count\n scenes {\n id\n title\n path\n }\n }\n}' , // eslint-disable-line
780779 'variables' : '{\n\t"variable_key": "variable_value"\n}'
781780 }
782781 } ,
@@ -793,21 +792,125 @@ describe('curl convert function', function () {
793792 }
794793 } ) ;
795794
796- // this needs to be done here because protocolProfileBehavior is not in collections SDK
797- request . protocolProfileBehavior = {
798- followOriginalHttpMethod : true
799- } ;
795+ convert ( request , { followRedirect : true , followOriginalHttpMethod : true } , function ( error , snippet ) {
796+ if ( error ) {
797+ expect . fail ( null , null , error ) ;
798+ }
799+ expect ( snippet ) . to . be . a ( 'string' ) ;
800+ expect ( snippet ) . to . include ( '--request POST' ) ;
801+ } ) ;
802+ } ) ;
803+
804+ it ( 'should not add --request parameter when passed false via options' , function ( ) {
805+ const request = new sdk . Request ( {
806+ 'method' : 'POST' ,
807+ 'header' : [ ] ,
808+ 'body' : {
809+ 'mode' : 'graphql' ,
810+ 'graphql' : {
811+ 'query' : '{\n findScenes(\n filter: {per_page: 0}\n scene_filter: {is_missing: "performers"}){\n count\n scenes {\n id\n title\n path\n }\n }\n}' , // eslint-disable-line
812+ 'variables' : '{\n\t"variable_key": "variable_value"\n}'
813+ }
814+ } ,
815+ 'url' : {
816+ 'raw' : 'https://postman-echo.com/post' ,
817+ 'protocol' : 'https' ,
818+ 'host' : [
819+ 'postman-echo' ,
820+ 'com'
821+ ] ,
822+ 'path' : [
823+ 'post'
824+ ]
825+ }
826+ } ) ;
827+
828+ convert ( request , { followRedirect : false , followOriginalHttpMethod : false } , function ( error , snippet ) {
829+ if ( error ) {
830+ expect . fail ( null , null , error ) ;
831+ }
832+ expect ( snippet ) . to . be . a ( 'string' ) ;
833+ expect ( snippet ) . to . not . include ( '--request POST' ) ;
834+ } ) ;
835+ } ) ;
836+
837+ it ( 'should add --request parameter when passed false via options but true in request settings' , function ( ) {
838+ const request = new sdk . Request ( {
839+ 'method' : 'POST' ,
840+ 'header' : [ ] ,
841+ 'body' : {
842+ 'mode' : 'graphql' ,
843+ 'graphql' : {
844+ 'query' : '{\n findScenes(\n filter: {per_page: 0}\n scene_filter: {is_missing: "performers"}){\n count\n scenes {\n id\n title\n path\n }\n }\n}' , // eslint-disable-line
845+ 'variables' : '{\n\t"variable_key": "variable_value"\n}'
846+ }
847+ } ,
848+ 'url' : {
849+ 'raw' : 'https://postman-echo.com/post' ,
850+ 'protocol' : 'https' ,
851+ 'host' : [
852+ 'postman-echo' ,
853+ 'com'
854+ ] ,
855+ 'path' : [
856+ 'post'
857+ ]
858+ }
859+ } ) ;
860+
861+ // this needs to be done here because protocolProfileBehavior is not in collections SDK
862+ request . protocolProfileBehavior = {
863+ followRedirects : true ,
864+ followOriginalHttpMethod : true
865+ } ;
800866
801- for ( let method of methods ) {
802- request . method = method ;
803- convert ( request , { followRedirect : true } , function ( error , snippet ) {
867+ convert ( request , { followRedirect : false , followOriginalHttpMethod : false } , function ( error , snippet ) {
804868 if ( error ) {
805869 expect . fail ( null , null , error ) ;
806870 }
807871 expect ( snippet ) . to . be . a ( 'string' ) ;
808- expect ( snippet ) . to . include ( ` --request ${ method } ` ) ;
872+ expect ( snippet ) . to . include ( ' --request POST' ) ;
809873 } ) ;
810- }
874+ } ) ;
875+
876+ it ( 'should not add --request parameter when passed true via options but false in request settings' , function ( ) {
877+ const request = new sdk . Request ( {
878+ 'method' : 'POST' ,
879+ 'header' : [ ] ,
880+ 'body' : {
881+ 'mode' : 'graphql' ,
882+ 'graphql' : {
883+ 'query' : '{\n findScenes(\n filter: {per_page: 0}\n scene_filter: {is_missing: "performers"}){\n count\n scenes {\n id\n title\n path\n }\n }\n}' , // eslint-disable-line
884+ 'variables' : '{\n\t"variable_key": "variable_value"\n}'
885+ }
886+ } ,
887+ 'url' : {
888+ 'raw' : 'https://postman-echo.com/post' ,
889+ 'protocol' : 'https' ,
890+ 'host' : [
891+ 'postman-echo' ,
892+ 'com'
893+ ] ,
894+ 'path' : [
895+ 'post'
896+ ]
897+ }
898+ } ) ;
899+
900+ // this needs to be done here because protocolProfileBehavior is not in collections SDK
901+ request . protocolProfileBehavior = {
902+ followRedirects : false ,
903+ followOriginalHttpMethod : false
904+ } ;
905+
906+ convert ( request , { followRedirect : true , followOriginalHttpMethod : true } , function ( error , snippet ) {
907+ if ( error ) {
908+ expect . fail ( null , null , error ) ;
909+ }
910+ expect ( snippet ) . to . be . a ( 'string' ) ;
911+ expect ( snippet ) . to . not . include ( '--request POST' ) ;
912+ } ) ;
913+ } ) ;
811914 } ) ;
812915 } ) ;
813916} ) ;
0 commit comments