@@ -20,6 +20,11 @@ describe('API Console navigation', () => {
2020 ` ) ) ;
2121 }
2222
23+ const testEndpoint = ( endpoint , path , name ) => {
24+ assert . equal ( endpoint . getAttribute ( 'data-endpoint-path' ) , path )
25+ assert . equal ( endpoint . querySelector ( '.endpoint-name' ) . innerText , name )
26+ }
27+
2328 const googleApi = 'google-drive-api' ;
2429
2530 [
@@ -74,11 +79,6 @@ describe('API Console navigation', () => {
7479 } ) ;
7580
7681 describe ( 'Endpoints section' , ( ) => {
77- const testEndpoint = ( endpoint , path , name ) => {
78- assert . equal ( endpoint . getAttribute ( 'data-endpoint-path' ) , path )
79- assert . equal ( endpoint . querySelector ( '.endpoint-name' ) . innerText , name )
80- }
81-
8282 const testGoogleEndpoints = ( elem , fullPaths = false ) => {
8383 const endpointsList = navigationEndpointsList ( elem ) ;
8484 assert . ok ( endpointsList ) ;
@@ -325,4 +325,181 @@ describe('API Console navigation', () => {
325325 } ) ;
326326 } ) ;
327327 } ) ;
328+
329+ [
330+ new ApiDescribe ( 'Regular model' ) ,
331+ new ApiDescribe ( 'Compact model' , true )
332+ ] . forEach ( ( { label, compact} ) => {
333+ describe ( label , ( ) => {
334+ let element ;
335+ let amf ;
336+
337+ describe ( 'RAML Fragments' , ( ) => {
338+ describe ( 'SecurityScheme fragment' , ( ) => {
339+ before ( async ( ) => {
340+ amf = await AmfLoader . load ( { compact, fileName : 'basicAuth' } ) ;
341+ } ) ;
342+
343+ beforeEach ( async ( ) => {
344+ element = await amfFixture ( amf ) ;
345+ } ) ;
346+
347+ it ( `should only render security section` , async ( ) => {
348+ assert . notOk ( navigationSummarySection ( element ) ) ;
349+ assert . notOk ( navigationEndpointsSection ( element ) ) ;
350+ assert . notOk ( navigationDocumentationSection ( element ) ) ;
351+ assert . notOk ( navigationTypesSection ( element ) ) ;
352+ assert . ok ( navigationSecuritySection ( element ) ) ;
353+ } ) ;
354+
355+ it ( `should list all security items` , async ( ) => {
356+ const securityList = navigationSecurityList ( element ) ;
357+ assert . ok ( securityList ) ;
358+ assert . lengthOf ( securityList , 1 ) ;
359+ assert . equal ( securityList [ 0 ] . innerText . trim ( ) , 'BasicAuth' ) ;
360+ } ) ;
361+ } ) ;
362+
363+ describe ( 'DocumentationItem fragment' , ( ) => {
364+ before ( async ( ) => {
365+ amf = await AmfLoader . load ( { compact, fileName : 'documentation' } ) ;
366+ } ) ;
367+
368+ beforeEach ( async ( ) => {
369+ element = await amfFixture ( amf ) ;
370+ } ) ;
371+
372+ it ( `should only render documentation section` , async ( ) => {
373+ assert . notOk ( navigationSummarySection ( element ) ) ;
374+ assert . notOk ( navigationEndpointsSection ( element ) ) ;
375+ assert . ok ( navigationDocumentationSection ( element ) ) ;
376+ assert . notOk ( navigationTypesSection ( element ) ) ;
377+ assert . notOk ( navigationSecuritySection ( element ) ) ;
378+ } ) ;
379+
380+ it ( `should list all documentation items` , async ( ) => {
381+ const documentationList = navigationDocumentationList ( element ) ;
382+ assert . ok ( documentationList ) ;
383+ assert . lengthOf ( documentationList , 1 ) ;
384+ assert . equal ( documentationList [ 0 ] . innerText . trim ( ) , 'Home' ) ;
385+ } ) ;
386+ } ) ;
387+
388+ describe ( 'Extension fragment' , ( ) => {
389+ before ( async ( ) => {
390+ amf = await AmfLoader . load ( { compact, fileName : 'extension' } ) ;
391+ } ) ;
392+
393+ beforeEach ( async ( ) => {
394+ element = await amfFixture ( amf ) ;
395+ } ) ;
396+
397+ it ( `should render all extended elements` , async ( ) => {
398+ assert . ok ( navigationSummarySection ( element ) ) ;
399+ assert . ok ( navigationEndpointsSection ( element ) ) ;
400+ assert . notOk ( navigationDocumentationSection ( element ) ) ;
401+ assert . notOk ( navigationTypesSection ( element ) ) ;
402+ assert . notOk ( navigationSecuritySection ( element ) ) ;
403+ } ) ;
404+
405+ it ( `should list all endpoints` , async ( ) => {
406+ const endpointsList = navigationEndpointsList ( element ) ;
407+ assert . ok ( endpointsList ) ;
408+ assert . lengthOf ( endpointsList , 1 ) ;
409+ testEndpoint ( endpointsList [ 0 ] , "/test-v2" , "/test-v2" ) ;
410+ } ) ;
411+ } ) ;
412+
413+ describe ( 'Library fragment' , ( ) => {
414+ before ( async ( ) => {
415+ amf = await AmfLoader . load ( { compact, fileName : 'library' } ) ;
416+ } ) ;
417+
418+ beforeEach ( async ( ) => {
419+ element = await amfFixture ( amf ) ;
420+ } ) ;
421+
422+ it ( `should only render types section` , async ( ) => {
423+ assert . notOk ( navigationSummarySection ( element ) ) ;
424+ assert . notOk ( navigationEndpointsSection ( element ) ) ;
425+ assert . notOk ( navigationDocumentationSection ( element ) ) ;
426+ assert . ok ( navigationTypesSection ( element ) ) ;
427+ assert . notOk ( navigationSecuritySection ( element ) ) ;
428+ } ) ;
429+
430+ it ( `should list all type items` , async ( ) => {
431+ const documentationList = navigationTypesList ( element ) ;
432+ assert . ok ( documentationList ) ;
433+ assert . lengthOf ( documentationList , 1 ) ;
434+ assert . equal ( documentationList [ 0 ] . innerText . trim ( ) , 'myType' )
435+ } ) ;
436+ } ) ;
437+
438+ describe ( 'Overlay fragment' , ( ) => {
439+ before ( async ( ) => {
440+ amf = await AmfLoader . load ( { compact, fileName : 'overlay' } ) ;
441+ } ) ;
442+
443+ beforeEach ( async ( ) => {
444+ element = await amfFixture ( amf ) ;
445+ } ) ;
446+
447+ it ( `should render all sections in spec` , async ( ) => {
448+ assert . ok ( navigationSummarySection ( element ) ) ;
449+ assert . ok ( navigationEndpointsSection ( element ) ) ;
450+ assert . notOk ( navigationDocumentationSection ( element ) ) ;
451+ assert . notOk ( navigationTypesSection ( element ) ) ;
452+ assert . ok ( navigationSecuritySection ( element ) ) ;
453+ } ) ;
454+
455+ it ( `should list all endpoints` , async ( ) => {
456+ const endpointsList = navigationEndpointsList ( element ) ;
457+ assert . ok ( endpointsList ) ;
458+ assert . lengthOf ( endpointsList , 4 ) ;
459+
460+ [
461+ [ "/test-headers" , "Headers V2" ] ,
462+ [ "/test-custom-scheme" , "Custom security scheme" ] ,
463+ [ "/test-oauth10-scheme" , "Oauth 1.0 security scheme" ] ,
464+ [ "/test-oauth20-scheme" , "Oauth 2.0 security scheme" ]
465+ ] . forEach ( ( [ path , name ] , index ) => testEndpoint ( endpointsList [ index ] , path , name ) )
466+ } ) ;
467+
468+ it ( `should list all security items` , async ( ) => {
469+ const securityList = navigationSecurityList ( element ) ;
470+ assert . ok ( securityList ) ;
471+ assert . lengthOf ( securityList , 3 ) ;
472+ assert . equal ( securityList [ 0 ] . innerText . trim ( ) , 'customScheme - x-custom' ) ;
473+ assert . equal ( securityList [ 1 ] . innerText . trim ( ) , 'oauth_1_0 - OAuth 1.0' ) ;
474+ assert . equal ( securityList [ 2 ] . innerText . trim ( ) , 'oauth_2_0 - OAuth 2.0' ) ;
475+ } ) ;
476+ } ) ;
477+
478+ describe ( 'DataType fragment' , ( ) => {
479+ before ( async ( ) => {
480+ amf = await AmfLoader . load ( { compact, fileName : 'person' } ) ;
481+ } ) ;
482+
483+ beforeEach ( async ( ) => {
484+ element = await amfFixture ( amf ) ;
485+ } ) ;
486+
487+ it ( `should render all sections in spec` , async ( ) => {
488+ assert . notOk ( navigationSummarySection ( element ) ) ;
489+ assert . notOk ( navigationEndpointsSection ( element ) ) ;
490+ assert . notOk ( navigationDocumentationSection ( element ) ) ;
491+ assert . ok ( navigationTypesSection ( element ) ) ;
492+ assert . notOk ( navigationSecuritySection ( element ) ) ;
493+ } ) ;
494+
495+ it ( `should list all type items` , async ( ) => {
496+ const documentationList = navigationTypesList ( element ) ;
497+ assert . ok ( documentationList ) ;
498+ assert . lengthOf ( documentationList , 1 ) ;
499+ assert . equal ( documentationList [ 0 ] . innerText . trim ( ) , 'type' )
500+ } ) ;
501+ } ) ;
502+ } ) ;
503+ } ) ;
504+ } ) ;
328505} ) ;
0 commit comments