88 downloadRestApi ,
99 downloadRestApis ,
1010 searchExchange ,
11- getVersionByDeployment ,
11+ getApiVersions ,
1212 getSpecificApi ,
1313 getAsset ,
1414 runFetch ,
@@ -33,9 +33,6 @@ const assetSearchResults = require("../../testResources/download/resources/asset
3333// eslint-disable-next-line @typescript-eslint/no-var-requires
3434const getAssetWithVersion = require ( "../../testResources/download/resources/getAssetWithVersion" ) ;
3535
36- // eslint-disable-next-line @typescript-eslint/no-var-requires
37- const getAssetWithVersionV2 = require ( "../../testResources/download/resources/getAssetWithVersionV2" ) ;
38-
3936// eslint-disable-next-line @typescript-eslint/no-var-requires
4037const getAssetWithoutVersion = require ( "../../testResources/download/resources/getAsset" ) ;
4138
@@ -234,39 +231,22 @@ describe("exchangeDownloader", () => {
234231 } ) ;
235232 } ) ;
236233
237- describe ( "getVersionByDeployment " , ( ) => {
234+ describe ( "getApiVersions " , ( ) => {
238235 const scope = nock ( "https://anypoint.mulesoft.com/exchange/api/v1/assets" ) ;
239236
240- it ( "should return the latest version if no deployment is specified" , async ( ) => {
241- scope . get ( "/8888888/test-api" ) . reply ( 200 , getAssetWithoutVersion ) ;
242-
243- return expect (
244- getVersionByDeployment ( "AUTH_TOKEN" , REST_API )
245- ) . to . eventually . equal ( "0.0.42" ) ;
246- } ) ;
247-
248- it ( "should return the latest version if a deployment exists" , async ( ) => {
237+ it ( "should return the latest version" , async ( ) => {
249238 scope . get ( "/8888888/test-api" ) . reply ( 200 , getAssetWithoutVersion ) ;
250239
251240 return expect (
252- getVersionByDeployment ( "AUTH_TOKEN" , REST_API , / p r o d u c t i o n / i)
253- ) . to . eventually . equal ( "0.0.42" ) ;
254- } ) ;
255-
256- it ( "should return the latest version if the deployment does not exist" , async ( ) => {
257- scope . get ( "/8888888/test-api" ) . reply ( 200 , getAssetWithoutVersion ) ;
258-
259- return expect (
260- getVersionByDeployment ( "AUTH_TOKEN" , REST_API , / N O T A V A I L A B L E / i)
261- ) . to . eventually . equal ( "0.0.42" ) ;
241+ getApiVersions ( "AUTH_TOKEN" , REST_API )
242+ ) . to . eventually . deep . equal ( [ "0.1.1" ] ) ;
262243 } ) ;
263244
264245 it ( "should return undefined if the asset does not exist" , async ( ) => {
265246 scope . get ( "/8888888/test-api" ) . reply ( 404 , "Not Found" ) ;
266247
267- return expect (
268- getVersionByDeployment ( "AUTH_TOKEN" , REST_API , / N O T A V A I L A B L E / i)
269- ) . to . eventually . be . undefined ;
248+ return expect ( getApiVersions ( "AUTH_TOKEN" , REST_API ) ) . to . eventually . be
249+ . undefined ;
270250 } ) ;
271251
272252 it ( "should return undefined if the asset does not have a version" , async ( ) => {
@@ -275,9 +255,8 @@ describe("exchangeDownloader", () => {
275255
276256 scope . get ( "/8888888/test-api" ) . reply ( 200 , assetWithoutVersion ) ;
277257
278- return expect (
279- getVersionByDeployment ( "AUTH_TOKEN" , REST_API , / N O T A V A I L A B L E / i)
280- ) . to . eventually . be . undefined ;
258+ return expect ( getApiVersions ( "AUTH_TOKEN" , REST_API ) ) . to . eventually . be
259+ . undefined ;
281260 } ) ;
282261 } ) ;
283262
@@ -343,7 +322,7 @@ describe("exchangeDownloader", () => {
343322 scope
344323 . get ( "/shop-products-categories-api-v1" )
345324 . reply ( 200 , getAssetWithVersion )
346- . get ( "/shop-products-categories-api-v1/0.0.42 " )
325+ . get ( "/shop-products-categories-api-v1/0.1.1 " )
347326 . reply ( 200 , getAssetWithVersion ) ;
348327
349328 return expect ( search ( "searchString" ) ) . to . eventually . deep . equal ( [
@@ -354,76 +333,7 @@ describe("exchangeDownloader", () => {
354333 it ( "works when an asset does not exist" , ( ) => {
355334 scope . get ( "/shop-products-categories-api-v1" ) . reply ( 404 , "Not Found" ) ;
356335
357- return expect ( search ( "searchString" ) ) . to . eventually . deep . equal ( [
358- {
359- id : null ,
360- name : "Shopper Products" ,
361- description :
362- "Enable developers to add functionality that shows product details in shopping apps." ,
363- updatedDate : null ,
364- groupId : "893f605e-10e2-423a-bdb4-f952f56eb6d8" ,
365- assetId : "shop-products-categories-api-v1" ,
366- version : null ,
367- categories : {
368- "API layer" : [ "Process" ] ,
369- "CC API Family" : [ "Product" ] ,
370- "CC Version Status" : [ "Beta" ] ,
371- "CC API Visibility" : [ "External" ] ,
372- } ,
373- fatRaml : {
374- classifier : "fat-raml" ,
375- packaging : "zip" ,
376- createdDate : null ,
377- md5 : null ,
378- sha1 : null ,
379- mainFile : "shop-products-categories-api-v1.raml" ,
380- } ,
381- fatOas : null ,
382- } ,
383- ] ) ;
384- } ) ;
385-
386- it ( "works when there are no matches for the specified deployment" , ( ) => {
387- const asset = _ . cloneDeep ( shopperCustomersAsset ) ;
388- asset . id = "893f605e-10e2-423a-bdb4-f952f56eb6d8/shopper-customers/0.0.7" ;
389- asset . version = "0.0.7" ;
390- asset . fatRaml = {
391- classifier : "fat-raml" ,
392- packaging : "zip" ,
393- externalLink : "https://short.url/test" ,
394- createdDate : "2020-02-05T21:26:01.199Z" ,
395- md5 : "87b3ad2b2aa17639b52f0cc83c5a8d40" ,
396- sha1 : "f2b9b2de50b7250616e2eea8843735b57235c22b" ,
397- mainFile : "shopper-customers.raml" ,
398- } ;
399-
400- scope
401- . get ( "/shop-products-categories-api-v1" )
402- . reply ( 200 , getAssetWithoutVersion )
403- . get ( "/shop-products-categories-api-v1/0.0.42" )
404- . reply ( 200 , getAssetWithoutVersion ) ;
405-
406- return expect ( search ( "searchString" ) ) . to . eventually . deep . equal ( [ asset ] ) ;
407- } ) ;
408-
409- /**
410- * Returns root asset version when production tag is not found
411- * on V2 API response. The actual deployed version is available
412- * under otherVersions attributes, that has no external link to download
413- * and no environmentName attribute to match
414- */
415- it ( "returns the root asset version without production tag on V2 response" , ( ) => {
416- const asset = _ . cloneDeep ( shopperCustomersAsset ) ;
417- asset . id = "893f605e-10e2-423a-bdb4-f952f56eb6d8/shopper-customers/0.5.0" ;
418- asset . version = "0.5.0" ;
419- asset . fatRaml . externalLink = "https://somewhere/fatraml.zip" ;
420- scope
421- . get ( "/shop-products-categories-api-v1" )
422- . reply ( 200 , getAssetWithVersionV2 )
423- . get ( "/shop-products-categories-api-v1/0.5.0" )
424- . reply ( 200 , getAssetWithVersionV2 ) ;
425-
426- return expect ( search ( "searchString" ) ) . to . eventually . deep . equal ( [ asset ] ) ;
336+ return expect ( search ( "searchString" ) ) . to . eventually . deep . equal ( [ ] ) ;
427337 } ) ;
428338 } ) ;
429339
0 commit comments