@@ -43,14 +43,22 @@ describe('rest', () => {
4343 it ( 'should request org limits and default to "GET" HTTP method' , async ( ) => {
4444 nock ( testOrg . instanceUrl ) . get ( '/services/data/v56.0/limits' ) . reply ( 200 , orgLimitsResponse ) ;
4545
46- await Rest . run ( [ 'services/data/v56.0/limits' , '--target-org' , '[email protected] ' ] ) ; 46+ await Rest . run ( [ '--api-version' , '56.0' , 'limits' , '--target-org' , '[email protected] ' ] ) ; 47+
48+ expect ( uxStub . styledJSON . args [ 0 ] [ 0 ] ) . to . deep . equal ( orgLimitsResponse ) ;
49+ } ) ;
50+
51+ it ( "should strip leading '/'" , async ( ) => {
52+ nock ( testOrg . instanceUrl ) . get ( '/services/data/v56.0/limits' ) . reply ( 200 , orgLimitsResponse ) ;
53+
54+ await Rest . run ( [ '--api-version' , '56.0' , '/limits' , '--target-org' , '[email protected] ' ] ) ; 4755
4856 expect ( uxStub . styledJSON . args [ 0 ] [ 0 ] ) . to . deep . equal ( orgLimitsResponse ) ;
4957 } ) ;
5058
5159 it ( 'should throw error for invalid header args' , async ( ) => {
5260 try {
53- await Rest . run ( [ 'services/data/v56.0/ limits' , '--target-org' , '[email protected] ' , '-H' , 'myInvalidHeader' ] ) ; 61+ await Rest . run ( [ 'limits' , '--target-org' , '[email protected] ' , '-H' , 'myInvalidHeader' ] ) ; 5462 assert . fail ( 'the above should throw' ) ;
5563 } catch ( e ) {
5664 expect ( ( e as SfError ) . name ) . to . equal ( 'Failed To Parse HTTP Header' ) ;
@@ -64,7 +72,15 @@ describe('rest', () => {
6472 it ( 'should redirect to file' , async ( ) => {
6573 nock ( testOrg . instanceUrl ) . get ( '/services/data/v56.0/limits' ) . reply ( 200 , orgLimitsResponse ) ;
6674 const writeSpy = $$ . SANDBOX . stub ( process . stdout , 'write' ) ;
67- await Rest . run ( [ 'services/data/v56.0/limits' , '--target-org' , '[email protected] ' , '--stream-to-file' , 'myOutput.txt' ] ) ; 75+ await Rest . run ( [
76+ '--api-version' ,
77+ '56.0' ,
78+ 'limits' ,
79+ '--target-org' ,
80+ 81+ '--stream-to-file' ,
82+ 'myOutput.txt' ,
83+ ] ) ;
6884
6985 // gives it a second to resolve promises and close streams before we start asserting
7086 await sleep ( 1000 ) ;
@@ -93,10 +109,20 @@ describe('rest', () => {
93109 accept : 'application/xml' ,
94110 } ,
95111 } )
96- . get ( '/services/data' )
112+ . get ( '/services/data/v42.0/ ' )
97113 . reply ( 200 , xmlRes ) ;
98114
99- await Rest . run ( [ 'services/data' , '--header' , 'Accept: application/xml' , '--target-org' , '[email protected] ' ] ) ; 115+ await Rest . run ( [
116+ '' ,
117+ '--api-version' ,
118+ '42.0' ,
119+ '--method' ,
120+ 'GET' ,
121+ '--header' ,
122+ 'Accept: application/xml' ,
123+ '--target-org' ,
124+ 125+ ] ) ;
100126
101127 const output = stripAnsi ( writeSpy . args . flat ( ) . join ( '' ) ) ;
102128
@@ -126,7 +152,7 @@ describe('rest', () => {
126152 location : `${ testOrg . instanceUrl } /services/data/v56.0/limits` ,
127153 } ) ;
128154
129- await Rest . run ( [ 'services/data/v56.0/limites ' , '--target-org' , '[email protected] ' ] ) ; 155+ await Rest . run ( [ 'limites' , '--api-version' , '56.0 ', '--target-org' , '[email protected] ' ] ) ; 130156
131157 expect ( uxStub . styledJSON . args [ 0 ] [ 0 ] ) . to . deep . equal ( orgLimitsResponse ) ;
132158 } ) ;
0 commit comments