@@ -23,6 +23,7 @@ import Table from 'docc-render/components/ContentNode/Table.vue';
2323import LinkableHeading from 'docc-render/components/ContentNode/LinkableHeading.vue' ;
2424import StrikeThrough from 'docc-render/components/ContentNode/StrikeThrough.vue' ;
2525import Small from '@/components/ContentNode/Small.vue' ;
26+ import BlockVideo from '@/components/ContentNode/BlockVideo.vue' ;
2627
2728const { TableHeaderStyle } = ContentNode . constants ;
2829
@@ -475,12 +476,13 @@ describe('ContentNode', () => {
475476 expect ( caption . exists ( ) ) . toBe ( true ) ;
476477 expect ( caption . contains ( 'p' ) ) . toBe ( true ) ;
477478 expect ( caption . props ( 'title' ) ) . toBeFalsy ( ) ;
479+ expect ( caption . props ( 'centered' ) ) . toBe ( true ) ;
478480 expect ( caption . text ( ) ) . toContain ( 'blah' ) ;
479481 // assert figurerecaption is below the image
480482 expect ( figure . html ( ) ) . toMatchInlineSnapshot ( `
481483 <figure-stub>
482484 <inlineimage-stub alt="" variants="[object Object],[object Object]"></inlineimage-stub>
483- <figurecaption-stub>
485+ <figurecaption-stub centered="true" >
484486 <p>blah</p>
485487 </figurecaption-stub>
486488 </figure-stub>
@@ -531,6 +533,102 @@ describe('ContentNode', () => {
531533 } ) ;
532534 } ) ;
533535
536+ describe ( 'with type="video"' , ( ) => {
537+ const identifier = 'video.mp4' ;
538+ const references = {
539+ [ identifier ] : {
540+ identifier,
541+ variants : [
542+ {
543+ traits : [ '2x' , 'light' ] ,
544+ url : '' ,
545+ size : { width : 1202 , height : 630 } ,
546+ } ,
547+ ] ,
548+ } ,
549+ } ;
550+
551+ it ( 'renders an `BlockVideo`' , ( ) => {
552+ const wrapper = mountWithItem ( {
553+ type : 'video' ,
554+ identifier,
555+ } , references ) ;
556+
557+ const inlineVideo = wrapper . find ( '.content' ) . find ( BlockVideo ) ;
558+ expect ( inlineVideo . exists ( ) ) . toBe ( true ) ;
559+ expect ( inlineVideo . props ( 'identifier' ) ) . toEqual ( identifier ) ;
560+ } ) ;
561+
562+ it ( 'does not crash with missing video reference data' , ( ) => {
563+ expect ( ( ) => mountWithItem ( {
564+ type : 'video' ,
565+ identifier,
566+ } , { } ) ) . not . toThrow ( ) ;
567+ } ) ;
568+
569+ it ( 'renders a `Figure`/`FigureCaption` with metadata' , ( ) => {
570+ const metadata = {
571+ anchor : 'foo' ,
572+ abstract : [ {
573+ type : 'paragraph' ,
574+ inlineContent : [ { type : 'text' , text : 'blah' } ] ,
575+ } ] ,
576+ } ;
577+ const wrapper = mountWithItem ( {
578+ type : 'video' ,
579+ identifier,
580+ metadata,
581+ } , references ) ;
582+
583+ const figure = wrapper . find ( Figure ) ;
584+ expect ( figure . exists ( ) ) . toBe ( true ) ;
585+ expect ( figure . props ( 'anchor' ) ) . toBe ( 'foo' ) ;
586+ expect ( figure . contains ( BlockVideo ) ) . toBe ( true ) ;
587+
588+ const caption = wrapper . find ( FigureCaption ) ;
589+ expect ( caption . exists ( ) ) . toBe ( true ) ;
590+ expect ( caption . contains ( 'p' ) ) . toBe ( true ) ;
591+ expect ( caption . props ( 'title' ) ) . toBe ( metadata . title ) ;
592+ expect ( caption . props ( 'centered' ) ) . toBe ( true ) ;
593+ expect ( caption . text ( ) ) . toContain ( 'blah' ) ;
594+ } ) ;
595+
596+ it ( 'renders a `Figure`/`FigureCaption` without an anchor, with text under the video' , ( ) => {
597+ const metadata = {
598+ abstract : [ {
599+ type : 'paragraph' ,
600+ inlineContent : [ { type : 'text' , text : 'blah' } ] ,
601+ } ] ,
602+ } ;
603+ const wrapper = mountWithItem ( {
604+ type : 'video' ,
605+ identifier,
606+ metadata,
607+ } , references ) ;
608+
609+ const figure = wrapper . find ( Figure ) ;
610+ expect ( figure . exists ( ) ) . toBe ( true ) ;
611+ expect ( figure . props ( 'anchor' ) ) . toBeFalsy ( ) ;
612+ expect ( figure . contains ( BlockVideo ) ) . toBe ( true ) ;
613+
614+ const caption = wrapper . find ( FigureCaption ) ;
615+ expect ( caption . exists ( ) ) . toBe ( true ) ;
616+ expect ( caption . contains ( 'p' ) ) . toBe ( true ) ;
617+ expect ( caption . props ( 'title' ) ) . toBeFalsy ( ) ;
618+ expect ( caption . props ( 'centered' ) ) . toBe ( true ) ;
619+ expect ( caption . text ( ) ) . toContain ( 'blah' ) ;
620+ // assert figurerecaption is below the image
621+ expect ( figure . html ( ) ) . toMatchInlineSnapshot ( `
622+ <figure-stub>
623+ <blockvideo-stub identifier="video.mp4"></blockvideo-stub>
624+ <figurecaption-stub centered="true">
625+ <p>blah</p>
626+ </figurecaption-stub>
627+ </figure-stub>
628+ ` ) ;
629+ } ) ;
630+ } ) ;
631+
534632 describe ( 'with type="link"' , ( ) => {
535633 it ( 'renders a <a>' , ( ) => {
536634 const wrapper = mountWithItem ( {
@@ -969,6 +1067,7 @@ describe('ContentNode', () => {
9691067 const caption = figure . find ( FigureCaption ) ;
9701068 expect ( caption . exists ( ) ) . toBe ( true ) ;
9711069 expect ( caption . props ( 'title' ) ) . toBe ( metadata . title ) ;
1070+ expect ( caption . props ( 'centered' ) ) . toBe ( false ) ;
9721071 expect ( caption . contains ( 'p' ) ) . toBe ( true ) ;
9731072 expect ( caption . text ( ) ) . toContain ( 'blah' ) ;
9741073 } ) ;
0 commit comments