@@ -14,6 +14,14 @@ describe('ApiSummary', () => {
1414 return fixture ( html `< api-summary > </ api-summary > ` ) ;
1515 }
1616
17+ /**
18+ * @returns {Promise<ApiSummary> }
19+ */
20+ async function agentFixture ( ) {
21+ const amf = await AmfLoader . load ( false , 'agents-api' ) ;
22+ return fixture ( html `< api-summary .amf ="${ amf } "> </ api-summary > ` ) ;
23+ }
24+
1725 /**
1826 * @param {any } amf
1927 * @returns {Promise<ApiSummary> }
@@ -349,116 +357,22 @@ describe('ApiSummary', () => {
349357 } ) ;
350358 } ) ;
351359
352- describe ( ' Endpoints rendering with agents' , ( ) => {
360+ describe ( " Endpoints rendering with agents" , ( ) => {
353361 let element = /** @type ApiSummary */ ( null ) ;
354- let amf ;
355-
356- before ( async ( ) => {
357- amf = await AmfLoader . load ( compact , 'agents-api' ) ;
358- } ) ;
359362
360363 beforeEach ( async ( ) => {
361- element = await basicFixture ( ) ;
362- element . amf = amf ;
364+ element = await agentFixture ( ) ;
363365 await aTimeout ( 0 ) ;
364366 } ) ;
365367
366- it ( 'adds separator' , ( ) => {
367- const node = element . shadowRoot . querySelector ( '.separator' ) ;
368- assert . ok ( node ) ;
369- } ) ;
370-
371- it ( 'renders all endpoints' , ( ) => {
372- const nodes = element . shadowRoot . querySelectorAll ( '.endpoint-item' ) ;
368+ it ( "renders the list of endpoints" , async ( ) => {
369+ const nodes = element . shadowRoot . querySelectorAll ( ".endpoint-item" ) ;
373370 assert . lengthOf ( nodes , 2 ) ;
374371 } ) ;
375372
376- it ( 'renders endpoint name' , ( ) => {
377- const node = element . shadowRoot . querySelectorAll ( '.endpoint-item' ) [ 1 ] . querySelector ( '.endpoint-path' ) ;
378- assert . dom . equal (
379- node ,
380- `<a
381- class="endpoint-path"
382- data-shape-type="endpoint"
383- href="#/reservations/reservationlookup"
384- title="Open endpoint documentation"
385- >
386- /reservations/reservationlookup
387- </a>` ,
388- {
389- ignoreAttributes : [ 'data-id' ]
390- }
391- ) ;
392- } ) ;
393-
394- it ( 'sets data-id on name' , ( ) => {
395- const node = element . shadowRoot . querySelectorAll ( '.endpoint-item' ) [ 1 ] . querySelector ( '.endpoint-path' ) ;
396- assert . ok ( node . getAttribute ( 'data-id' ) ) ;
397- } ) ;
398-
399- it ( 'sets data-id on path' , ( ) => {
400- const node = element . shadowRoot . querySelectorAll ( '.endpoint-item' ) [ 1 ] . querySelector ( '.endpoint-path' ) ;
401- assert . ok ( node . getAttribute ( 'data-id' ) ) ;
402- } ) ;
403-
404- it ( 'renders list of operations' , ( ) => {
405- const nodes = element . shadowRoot . querySelectorAll ( '.endpoint-item' ) [ 1 ] . querySelectorAll ( '.method-label' ) ;
406- assert . lengthOf ( nodes , 1 ) ;
407- } ) ;
408-
409- it ( 'renders operation method' , ( ) => {
410- const node = element . shadowRoot . querySelectorAll ( '.endpoint-item' ) [ 1 ] . querySelector ( '.method-label' ) ;
411- assert . dom . equal (
412- node ,
413- `<a
414- class="method-label method-label-with-icon"
415- data-method="get"
416- data-shape-type="method"
417- href="#/reservations/reservationlookup/get"
418- title="Open method documentation"
419- >get
420- <arc-icon class="method-icon" icon="codegenie"></arc-icon>
421- </a>` ,
422- {
423- ignoreAttributes : [ 'data-id' ]
424- }
425- ) ;
426- } ) ;
427-
428- it ( 'Click on an endpoint dispatches navigation event' , ( done ) => {
429- const node = element . shadowRoot . querySelector ( `.endpoint-path[data-id]` ) ;
430- element . addEventListener ( 'api-navigation-selection-changed' , ( e ) => {
431- // @ts -ignore
432- const { detail} = e ;
433- assert . typeOf ( detail . selected , 'string' ) ;
434- assert . equal ( detail . type , 'endpoint' ) ;
435- done ( ) ;
436- } ) ;
437- /** @type HTMLElement */ ( node ) . click ( ) ;
438- } ) ;
439-
440- it ( 'Click on an endpoint path dispatches navigation event' , ( done ) => {
441- const node = element . shadowRoot . querySelector ( `.endpoint-path[data-id]` ) ;
442- element . addEventListener ( 'api-navigation-selection-changed' , ( e ) => {
443- // @ts -ignore
444- const { detail} = e ;
445- assert . typeOf ( detail . selected , 'string' ) ;
446- assert . equal ( detail . type , 'endpoint' ) ;
447- done ( ) ;
448- } ) ;
449- /** @type HTMLElement */ ( node ) . click ( ) ;
450- } ) ;
451-
452- it ( 'Click on a method dispatches navigation event' , ( done ) => {
453- const node = element . shadowRoot . querySelector ( `.method-label[data-id]` ) ;
454- element . addEventListener ( 'api-navigation-selection-changed' , ( e ) => {
455- // @ts -ignore
456- const { detail} = e ;
457- assert . typeOf ( detail . selected , 'string' ) ;
458- assert . equal ( detail . type , 'method' ) ;
459- done ( ) ;
460- } ) ;
461- /** @type HTMLElement */ ( node ) . click ( ) ;
373+ it ( 'renders the agent pill' , async ( ) => {
374+ const node = element . shadowRoot . querySelector ( '.agent-pill' ) ;
375+ assert . ok ( node ) ;
462376 } ) ;
463377 } ) ;
464378
0 commit comments