@@ -8,18 +8,24 @@ describe('invalid api:validate', () => {
88
99 test . stub ( config , 'getConfig' , ( ) => ( { SWAGGERHUB_URL : 'https://api.swaggerhub.com' } ) )
1010 . nock ( 'https://api.swaggerhub.com/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
11- . get ( `/${ apiPath } /standardization ` )
11+ . get ( `/${ apiPath } ` )
1212 . reply ( 404 , {
1313 code : 404 ,
1414 message : `SPEC ${ apiPath } not found.`
1515 } )
1616 )
1717 . stdout ( )
1818 . command ( [ 'api:validate' , apiPath ] )
19- . exit ( 0 )
19+ . exit ( 2 )
2020 . it ( 'not found returned when fetching validation result of a non existing API' )
2121
2222 test . stub ( config , 'getConfig' , ( ) => ( { SWAGGERHUB_URL : 'https://api.swaggerhub.com' } ) )
23+ . nock ( 'https://api.swaggerhub.com/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
24+ . get ( `/${ apiPath } ` )
25+ . reply ( 200 , {
26+ code : 200
27+ } )
28+ )
2329 . nock ( 'https://api.swaggerhub.com/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
2430 . get ( `/${ apiPath } /standardization` )
2531 . reply ( 404 , {
@@ -33,6 +39,12 @@ describe('invalid api:validate', () => {
3339 . it ( 'not enabled returned when fetching validation result an existing' )
3440
3541 test . stub ( config , 'getConfig' , ( ) => ( { SWAGGERHUB_URL : 'https://api.swaggerhub.com' } ) )
42+ . nock ( 'https://api.swaggerhub.com/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
43+ . get ( `/${ apiPath } ` )
44+ . reply ( 200 , {
45+ code : 200
46+ } )
47+ )
3648 . nock ( 'https://api.swaggerhub.com/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
3749 . get ( `/${ apiPath } /standardization` )
3850 . reply ( 403 , {
@@ -54,6 +66,12 @@ describe('invalid api:validate', () => {
5466 . it ( 'not found returned when fetching default version of API' )
5567
5668 test . env ( { SWAGGERHUB_URL : 'https://example.com/v1' } )
69+ . nock ( 'https://example.com/v1/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
70+ . get ( `/${ apiPath } ` )
71+ . reply ( 200 , {
72+ code : 200
73+ } )
74+ )
5775 . nock ( 'https://example.com/v1/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
5876 . get ( `/${ apiPath } /standardization` )
5977 . reply ( 404 )
@@ -76,6 +94,12 @@ describe('valid api:validate for swaggerhub on-premise <= 2.4.1', () => {
7694 const severity = 'warning'
7795
7896 test . env ( { SWAGGERHUB_URL : 'https://example.com/v1' } )
97+ . nock ( 'https://example.com/v1/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
98+ . get ( `/${ apiPath } ` )
99+ . reply ( 200 , {
100+ code : 200
101+ } )
102+ )
79103 . nock ( 'https://example.com/v1/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
80104 . get ( `/${ apiPath } /standardization` )
81105 . reply ( 200 , {
@@ -107,6 +131,12 @@ describe('valid api:validate', () => {
107131
108132 describe ( 'without -c flag' , ( ) => {
109133 test . stub ( config , 'getConfig' , ( ) => ( { SWAGGERHUB_URL : 'https://api.swaggerhub.com' } ) )
134+ . nock ( 'https://api.swaggerhub.com/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
135+ . get ( `/${ apiPath } ` )
136+ . reply ( 200 , {
137+ code : 200
138+ } )
139+ )
110140 . nock ( 'https://api.swaggerhub.com/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
111141 . get ( `/${ apiPath } /standardization` )
112142 . reply ( 200 , {
@@ -125,6 +155,12 @@ describe('valid api:validate', () => {
125155
126156 describe ( 'with -c flag' , ( ) => {
127157 test . stub ( config , 'getConfig' , ( ) => ( { SWAGGERHUB_URL : 'https://api.swaggerhub.com' } ) )
158+ . nock ( 'https://api.swaggerhub.com/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
159+ . get ( `/${ apiPath } ` )
160+ . reply ( 200 , {
161+ code : 200
162+ } )
163+ )
128164 . nock ( 'https://api.swaggerhub.com/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
129165 . get ( `/${ apiPath } /standardization` )
130166 . reply ( 200 , {
@@ -143,6 +179,12 @@ describe('valid api:validate', () => {
143179
144180 describe ( 'with --fail-on-critical flag' , ( ) => {
145181 test . stub ( config , 'getConfig' , ( ) => ( { SWAGGERHUB_URL : 'https://api.swaggerhub.com' } ) )
182+ . nock ( 'https://api.swaggerhub.com/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
183+ . get ( `/${ apiPath } ` )
184+ . reply ( 200 , {
185+ code : 200
186+ } )
187+ )
146188 . nock ( 'https://api.swaggerhub.com/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
147189 . get ( `/${ apiPath } /standardization` )
148190 . reply ( 200 , {
@@ -165,6 +207,12 @@ describe('valid api:validate', () => {
165207
166208 describe ( 'without -c flag' , ( ) => {
167209 test . stub ( config , 'getConfig' , ( ) => ( { SWAGGERHUB_URL : 'https://api.swaggerhub.com' } ) )
210+ . nock ( 'https://api.swaggerhub.com/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
211+ . get ( `/${ apiPath } ` )
212+ . reply ( 200 , {
213+ code : 200
214+ } )
215+ )
168216 . nock ( 'https://api.swaggerhub.com/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
169217 . get ( `/${ apiPath } /standardization` )
170218 . reply ( 200 , {
@@ -182,7 +230,14 @@ describe('valid api:validate', () => {
182230 } )
183231
184232 describe ( 'with -c flag' , ( ) => {
233+
185234 test . stub ( config , 'getConfig' , ( ) => ( { SWAGGERHUB_URL : 'https://api.swaggerhub.com' } ) )
235+ . nock ( 'https://api.swaggerhub.com/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
236+ . get ( `/${ apiPath } ` )
237+ . reply ( 200 , {
238+ code : 200
239+ } )
240+ )
186241 . nock ( 'https://api.swaggerhub.com/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
187242 . get ( `/${ apiPath } /standardization` )
188243 . reply ( 200 , {
@@ -201,6 +256,12 @@ describe('valid api:validate', () => {
201256
202257 describe ( 'with --fail-on-critical flag' , ( ) => {
203258 test . stub ( config , 'getConfig' , ( ) => ( { SWAGGERHUB_URL : 'https://api.swaggerhub.com' } ) )
259+ . nock ( 'https://api.swaggerhub.com/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
260+ . get ( `/${ apiPath } ` )
261+ . reply ( 200 , {
262+ code : 200
263+ } )
264+ )
204265 . nock ( 'https://api.swaggerhub.com/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
205266 . get ( `/${ apiPath } /standardization` )
206267 . reply ( 200 , {
@@ -220,6 +281,12 @@ describe('valid api:validate', () => {
220281
221282 describe ( 'when no standardization errors present' , ( ) => {
222283 test . stub ( config , 'getConfig' , ( ) => ( { SWAGGERHUB_URL : 'https://api.swaggerhub.com' } ) )
284+ . nock ( 'https://api.swaggerhub.com/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
285+ . get ( `/${ apiPath } ` )
286+ . reply ( 200 , {
287+ code : 200
288+ } )
289+ )
223290 . nock ( 'https://api.swaggerhub.com/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
224291 . get ( `/${ apiPath } /standardization` )
225292 . reply ( 200 , {
@@ -234,6 +301,12 @@ describe('valid api:validate', () => {
234301 } )
235302
236303 test . stub ( config , 'getConfig' , ( ) => ( { SWAGGERHUB_URL : 'https://api.swaggerhub.com' } ) )
304+ . nock ( 'https://api.swaggerhub.com/apis' , { reqheaders : { Accept : 'application/json' } } , api => api
305+ . get ( `/${ apiPath } ` )
306+ . reply ( 200 , {
307+ code : 200
308+ } )
309+ )
237310 . nock ( 'https://api.swaggerhub.com/apis' , api => api
238311 . get ( `/${ apiPath . substring ( 0 , apiPath . lastIndexOf ( '/' ) ) } /settings/default` )
239312 . reply ( 200 , {
0 commit comments