@@ -431,6 +431,83 @@ describe('ContentNode', () => {
431431 expect ( caption . props ( 'title' ) ) . toBe ( metadata . title ) ;
432432 expect ( caption . text ( ) ) . toContain ( 'blah' ) ;
433433 } ) ;
434+
435+ it ( 'renders a `Figure`/`FigureCaption` without an anchor, with text under the image' , ( ) => {
436+ const metadata = {
437+ abstract : [ {
438+ type : 'paragraph' ,
439+ inlineContent : [ { type : 'text' , text : 'blah' } ] ,
440+ } ] ,
441+ } ;
442+ const wrapper = mountWithItem ( {
443+ type : 'image' ,
444+ identifier : 'figure1.png' ,
445+ metadata,
446+ } , references ) ;
447+
448+ const figure = wrapper . find ( Figure ) ;
449+ expect ( figure . exists ( ) ) . toBe ( true ) ;
450+ expect ( figure . props ( 'anchor' ) ) . toBeFalsy ( ) ;
451+ expect ( figure . contains ( InlineImage ) ) . toBe ( true ) ;
452+
453+ const caption = wrapper . find ( FigureCaption ) ;
454+ expect ( caption . exists ( ) ) . toBe ( true ) ;
455+ expect ( caption . contains ( 'p' ) ) . toBe ( true ) ;
456+ expect ( caption . props ( 'title' ) ) . toBeFalsy ( ) ;
457+ expect ( caption . text ( ) ) . toContain ( 'blah' ) ;
458+ // assert figurerecaption is below the image
459+ expect ( figure . html ( ) ) . toMatchInlineSnapshot ( `
460+ <figure-stub>
461+ <inlineimage-stub alt="" variants="[object Object],[object Object]"></inlineimage-stub>
462+ <figurecaption-stub>
463+ <p>blah</p>
464+ </figurecaption-stub>
465+ </figure-stub>
466+ ` ) ;
467+ } ) ;
468+
469+ it ( 'renders a `FigureCaption` before the image, if it has a title' , ( ) => {
470+ const metadata = {
471+ title : 'foo' ,
472+ abstract : [ {
473+ type : 'paragraph' ,
474+ inlineContent : [ { type : 'text' , text : 'blah' } ] ,
475+ } ] ,
476+ } ;
477+ const wrapper = mountWithItem ( {
478+ type : 'image' ,
479+ identifier : 'figure1.png' ,
480+ metadata,
481+ } , references ) ;
482+ expect ( wrapper . find ( Figure ) . html ( ) ) . toMatchInlineSnapshot ( `
483+ <figure-stub>
484+ <figurecaption-stub title="foo">
485+ <p>blah</p>
486+ </figurecaption-stub>
487+ <inlineimage-stub alt="" variants="[object Object],[object Object]"></inlineimage-stub>
488+ </figure-stub>
489+ ` ) ;
490+ } ) ;
491+
492+ it ( 'renders no `FigureCaption`, if there is a `title`, but no `abstract`' , ( ) => {
493+ const metadata = {
494+ postTitle : true ,
495+ title : 'Foo' ,
496+ anchor : 'foo-figure' ,
497+ } ;
498+ const wrapper = mountWithItem ( {
499+ type : 'image' ,
500+ identifier : 'figure1.png' ,
501+ metadata,
502+ } , references ) ;
503+
504+ const figure = wrapper . find ( Figure ) ;
505+ expect ( figure . exists ( ) ) . toBe ( true ) ;
506+ expect ( figure . props ( 'anchor' ) ) . toBe ( 'foo-figure' ) ;
507+ expect ( figure . contains ( InlineImage ) ) . toBe ( true ) ;
508+
509+ expect ( wrapper . find ( FigureCaption ) . exists ( ) ) . toBe ( false ) ;
510+ } ) ;
434511 } ) ;
435512
436513 describe ( 'with type="link"' , ( ) => {
0 commit comments