@@ -321,4 +321,103 @@ describe('generateOpenApiDocument', () => {
321321 expect ( result . paths [ '/v2-1' ] ! . get ! . tags ) . toEqual ( [ ] ) ;
322322 } ) ;
323323 } ) ;
324+
325+ describe ( 'availability' , ( ) => {
326+ it ( 'creates the expected availability entries' , ( ) => {
327+ const [ routers , versionedRouters ] = createTestRouters ( {
328+ routers : {
329+ testRouter1 : {
330+ routes : [
331+ {
332+ path : '/1-1/{id}/{path*}' ,
333+ options : { availability : { stability : 'experimental' } } ,
334+ } ,
335+ {
336+ path : '/1-2/{id}/{path*}' ,
337+ options : { availability : { stability : 'beta' } } ,
338+ } ,
339+ {
340+ path : '/1-3/{id}/{path*}' ,
341+ options : { availability : { stability : 'stable' } } ,
342+ } ,
343+ ] ,
344+ } ,
345+ testRouter2 : {
346+ routes : [ { path : '/2-1/{id}/{path*}' } ] ,
347+ } ,
348+ } ,
349+ versionedRouters : {
350+ testVersionedRouter1 : {
351+ routes : [
352+ {
353+ path : '/v1-1' ,
354+ options : {
355+ access : 'public' ,
356+ options : { availability : { stability : 'experimental' } } ,
357+ } ,
358+ } ,
359+ {
360+ path : '/v1-2' ,
361+ options : {
362+ access : 'public' ,
363+ options : { availability : { stability : 'beta' } } ,
364+ } ,
365+ } ,
366+ {
367+ path : '/v1-3' ,
368+ options : {
369+ access : 'public' ,
370+ options : { availability : { stability : 'stable' } } ,
371+ } ,
372+ } ,
373+ ] ,
374+ } ,
375+ testVersionedRouter2 : {
376+ routes : [ { path : '/v2-1' , options : { access : 'public' } } ] ,
377+ } ,
378+ } ,
379+ } ) ;
380+ const result = generateOpenApiDocument (
381+ {
382+ routers,
383+ versionedRouters,
384+ } ,
385+ {
386+ title : 'test' ,
387+ baseUrl : 'https://test.oas' ,
388+ version : '99.99.99' ,
389+ }
390+ ) ;
391+
392+ // router paths
393+ expect ( result . paths [ '/1-1/{id}/{path*}' ] ! . get ) . toMatchObject ( {
394+ 'x-state' : 'Technical Preview' ,
395+ } ) ;
396+ expect ( result . paths [ '/1-2/{id}/{path*}' ] ! . get ) . toMatchObject ( {
397+ 'x-state' : 'Beta' ,
398+ } ) ;
399+
400+ expect ( result . paths [ '/1-3/{id}/{path*}' ] ! . get ) . not . toMatchObject ( {
401+ 'x-state' : expect . any ( String ) ,
402+ } ) ;
403+ expect ( result . paths [ '/2-1/{id}/{path*}' ] ! . get ) . not . toMatchObject ( {
404+ 'x-state' : expect . any ( String ) ,
405+ } ) ;
406+
407+ // versioned router paths
408+ expect ( result . paths [ '/v1-1' ] ! . get ) . toMatchObject ( {
409+ 'x-state' : 'Technical Preview' ,
410+ } ) ;
411+ expect ( result . paths [ '/v1-2' ] ! . get ) . toMatchObject ( {
412+ 'x-state' : 'Beta' ,
413+ } ) ;
414+
415+ expect ( result . paths [ '/v1-3' ] ! . get ) . not . toMatchObject ( {
416+ 'x-state' : expect . any ( String ) ,
417+ } ) ;
418+ expect ( result . paths [ '/v2-1' ] ! . get ) . not . toMatchObject ( {
419+ 'x-state' : expect . any ( String ) ,
420+ } ) ;
421+ } ) ;
422+ } ) ;
324423} ) ;
0 commit comments