@@ -16,7 +16,7 @@ import ContentNode from 'docc-render/components/ContentNode.vue';
16
16
import DictionaryExample from 'docc-render/components/ContentNode/DictionaryExample.vue' ;
17
17
import EndpointExample from 'docc-render/components/ContentNode/EndpointExample.vue' ;
18
18
import Figure from 'docc-render/components/ContentNode/Figure.vue' ;
19
- import Caption from 'docc-render/components/ContentNode/Caption .vue' ;
19
+ import FigureCaption from 'docc-render/components/ContentNode/FigureCaption .vue' ;
20
20
import InlineImage from 'docc-render/components/ContentNode/InlineImage.vue' ;
21
21
import Reference from 'docc-render/components/ContentNode/Reference.vue' ;
22
22
import Table from 'docc-render/components/ContentNode/Table.vue' ;
@@ -112,6 +112,29 @@ describe('ContentNode', () => {
112
112
expect ( codeListing . props ( 'content' ) ) . toEqual ( listing . code ) ;
113
113
expect ( codeListing . isEmpty ( ) ) . toBe ( true ) ;
114
114
} ) ;
115
+
116
+ it ( 'renders a `Figure`/`Figcaption` with metadata' , ( ) => {
117
+ const metadata = {
118
+ anchor : '42' ,
119
+ title : 'Listing 42' ,
120
+ abstract : [ {
121
+ type : 'paragraph' ,
122
+ inlineContent : [ { type : 'text' , text : 'blah' } ] ,
123
+ } ] ,
124
+ } ;
125
+ const wrapper = mountWithItem ( { ...listing , metadata } ) ;
126
+
127
+ const figure = wrapper . find ( Figure ) ;
128
+ expect ( figure . exists ( ) ) . toBe ( true ) ;
129
+ expect ( figure . props ( 'anchor' ) ) . toBe ( metadata . anchor ) ;
130
+ expect ( figure . contains ( CodeListing ) ) . toBe ( true ) ;
131
+
132
+ const caption = figure . find ( FigureCaption ) ;
133
+ expect ( caption . exists ( ) ) . toBe ( true ) ;
134
+ expect ( caption . props ( 'title' ) ) . toBe ( metadata . title ) ;
135
+ expect ( caption . contains ( 'p' ) ) . toBe ( true ) ;
136
+ expect ( caption . text ( ) ) . toContain ( 'blah' ) ;
137
+ } ) ;
115
138
} ) ;
116
139
117
140
describe ( 'with type="endpointExample"' , ( ) => {
@@ -691,7 +714,7 @@ describe('ContentNode', () => {
691
714
} , { } ) ) . not . toThrow ( ) ;
692
715
} ) ;
693
716
694
- it ( 'renders a `Figure`/`Caption ` with metadata' , ( ) => {
717
+ it ( 'renders a `Figure`/`FigureCaption ` with metadata' , ( ) => {
695
718
const metadata = {
696
719
anchor : '42' ,
697
720
title : 'Figure 42' ,
@@ -711,14 +734,14 @@ describe('ContentNode', () => {
711
734
expect ( figure . props ( 'anchor' ) ) . toBe ( metadata . anchor ) ;
712
735
expect ( figure . contains ( InlineImage ) ) . toBe ( true ) ;
713
736
714
- const caption = wrapper . find ( Caption ) ;
737
+ const caption = wrapper . find ( FigureCaption ) ;
715
738
expect ( caption . exists ( ) ) . toBe ( true ) ;
716
739
expect ( caption . contains ( 'p' ) ) . toBe ( true ) ;
717
740
expect ( caption . props ( 'title' ) ) . toBe ( metadata . title ) ;
718
741
expect ( caption . text ( ) ) . toContain ( 'blah' ) ;
719
742
} ) ;
720
743
721
- it ( 'renders a `Figure`/`Caption ` without an anchor, with text under the image' , ( ) => {
744
+ it ( 'renders a `Figure`/`FigureCaption ` without an anchor, with text under the image' , ( ) => {
722
745
const metadata = {
723
746
abstract : [ {
724
747
type : 'paragraph' ,
@@ -736,7 +759,7 @@ describe('ContentNode', () => {
736
759
expect ( figure . props ( 'anchor' ) ) . toBeFalsy ( ) ;
737
760
expect ( figure . contains ( InlineImage ) ) . toBe ( true ) ;
738
761
739
- const caption = wrapper . find ( Caption ) ;
762
+ const caption = wrapper . find ( FigureCaption ) ;
740
763
expect ( caption . exists ( ) ) . toBe ( true ) ;
741
764
expect ( caption . contains ( 'p' ) ) . toBe ( true ) ;
742
765
expect ( caption . props ( 'title' ) ) . toBeFalsy ( ) ;
@@ -746,9 +769,9 @@ describe('ContentNode', () => {
746
769
expect ( figure . html ( ) ) . toMatchInlineSnapshot ( `
747
770
<figure-stub>
748
771
<inlineimage-stub alt="" variants="[object Object],[object Object]"></inlineimage-stub>
749
- <caption -stub centered="true" tag="figcaption ">
772
+ <figurecaption -stub centered="true">
750
773
<p>blah</p>
751
- </caption -stub>
774
+ </figurecaption -stub>
752
775
</figure-stub>
753
776
` ) ;
754
777
} ) ;
@@ -768,9 +791,9 @@ describe('ContentNode', () => {
768
791
} , references ) ;
769
792
expect ( wrapper . find ( Figure ) . html ( ) ) . toMatchInlineSnapshot ( `
770
793
<figure-stub>
771
- <caption -stub title="foo" tag="figcaption ">
794
+ <figurecaption -stub title="foo">
772
795
<p>blah</p>
773
- </caption -stub>
796
+ </figurecaption -stub>
774
797
<inlineimage-stub alt="" variants="[object Object],[object Object]"></inlineimage-stub>
775
798
</figure-stub>
776
799
` ) ;
@@ -793,7 +816,7 @@ describe('ContentNode', () => {
793
816
expect ( figure . props ( 'anchor' ) ) . toBe ( 'foo-figure' ) ;
794
817
expect ( figure . contains ( InlineImage ) ) . toBe ( true ) ;
795
818
796
- expect ( wrapper . find ( Caption ) . exists ( ) ) . toBe ( false ) ;
819
+ expect ( wrapper . find ( FigureCaption ) . exists ( ) ) . toBe ( false ) ;
797
820
} ) ;
798
821
799
822
it ( 'renders within a `DeviceFrame`' , ( ) => {
@@ -869,7 +892,7 @@ describe('ContentNode', () => {
869
892
} , { } ) ) . not . toThrow ( ) ;
870
893
} ) ;
871
894
872
- it ( 'renders a `Figure`/`Caption ` with metadata' , ( ) => {
895
+ it ( 'renders a `Figure`/`FigureCaption ` with metadata' , ( ) => {
873
896
const metadata = {
874
897
anchor : 'foo' ,
875
898
abstract : [ {
@@ -888,16 +911,15 @@ describe('ContentNode', () => {
888
911
expect ( figure . props ( 'anchor' ) ) . toBe ( 'foo' ) ;
889
912
expect ( figure . contains ( BlockVideo ) ) . toBe ( true ) ;
890
913
891
- const caption = wrapper . find ( Caption ) ;
914
+ const caption = wrapper . find ( FigureCaption ) ;
892
915
expect ( caption . exists ( ) ) . toBe ( true ) ;
893
- expect ( caption . props ( 'tag' ) ) . toBe ( 'figcaption' ) ;
894
916
expect ( caption . contains ( 'p' ) ) . toBe ( true ) ;
895
917
expect ( caption . props ( 'title' ) ) . toBe ( metadata . title ) ;
896
918
expect ( caption . props ( 'centered' ) ) . toBe ( true ) ;
897
919
expect ( caption . text ( ) ) . toContain ( 'blah' ) ;
898
920
} ) ;
899
921
900
- it ( 'renders a `Figure`/`Caption ` without an anchor, with text under the video' , ( ) => {
922
+ it ( 'renders a `Figure`/`FigureCaption ` without an anchor, with text under the video' , ( ) => {
901
923
const metadata = {
902
924
abstract : [ {
903
925
type : 'paragraph' ,
@@ -915,7 +937,7 @@ describe('ContentNode', () => {
915
937
expect ( figure . props ( 'anchor' ) ) . toBeFalsy ( ) ;
916
938
expect ( figure . contains ( BlockVideo ) ) . toBe ( true ) ;
917
939
918
- const caption = wrapper . find ( Caption ) ;
940
+ const caption = wrapper . find ( FigureCaption ) ;
919
941
expect ( caption . exists ( ) ) . toBe ( true ) ;
920
942
expect ( caption . contains ( 'p' ) ) . toBe ( true ) ;
921
943
expect ( caption . props ( 'title' ) ) . toBeFalsy ( ) ;
@@ -925,9 +947,9 @@ describe('ContentNode', () => {
925
947
expect ( figure . html ( ) ) . toMatchInlineSnapshot ( `
926
948
<figure-stub>
927
949
<blockvideo-stub identifier="video.mp4"></blockvideo-stub>
928
- <caption -stub centered="true" tag="figcaption ">
950
+ <figurecaption -stub centered="true">
929
951
<p>blah</p>
930
- </caption -stub>
952
+ </figurecaption -stub>
931
953
</figure-stub>
932
954
` ) ;
933
955
} ) ;
@@ -1350,33 +1372,6 @@ describe('ContentNode', () => {
1350
1372
expect ( table . findAll ( 'tbody tr td' ) . length ) . toBe ( 4 ) ;
1351
1373
} ) ;
1352
1374
1353
- it ( 'renders a `Table` with metadata' , ( ) => {
1354
- const metadata = {
1355
- anchor : '42' ,
1356
- title : 'Listing 42' ,
1357
- abstract : [ {
1358
- type : 'paragraph' ,
1359
- inlineContent : [ { type : 'text' , text : 'blah' } ] ,
1360
- } ] ,
1361
- } ;
1362
-
1363
- const wrapper = mountWithItem ( {
1364
- type : 'table' ,
1365
- header : TableHeaderStyle . none ,
1366
- rows,
1367
- metadata,
1368
- } ) ;
1369
-
1370
- const table = wrapper . find ( '.content' ) . find ( Table ) ;
1371
- expect ( table . exists ( ) ) . toBe ( true ) ;
1372
- expect ( table . attributes ( 'id' ) ) . toBe ( metadata . anchor ) ;
1373
-
1374
- const caption = wrapper . find ( Caption ) ;
1375
- expect ( caption . exists ( ) ) . toBe ( true ) ;
1376
- expect ( caption . props ( 'title' ) ) . toBe ( metadata . title ) ;
1377
- expect ( caption . text ( ) ) . toContain ( 'blah' ) ;
1378
- } ) ;
1379
-
1380
1375
it ( 'renders header="both" style tables' , ( ) => {
1381
1376
const wrapper = mountWithItem ( {
1382
1377
type : 'table' ,
@@ -1415,6 +1410,35 @@ describe('ContentNode', () => {
1415
1410
expect ( table . findAll ( 'tbody tr td' ) . length ) . toBe ( 2 ) ;
1416
1411
} ) ;
1417
1412
1413
+ it ( 'renders a `Figure`/`FigureCaption` with metadata' , ( ) => {
1414
+ const metadata = {
1415
+ anchor : '42' ,
1416
+ title : 'Table 42' ,
1417
+ abstract : [ {
1418
+ type : 'paragraph' ,
1419
+ inlineContent : [ { type : 'text' , text : 'blah' } ] ,
1420
+ } ] ,
1421
+ } ;
1422
+ const wrapper = mountWithItem ( {
1423
+ type : 'table' ,
1424
+ header : TableHeaderStyle . none ,
1425
+ rows,
1426
+ metadata,
1427
+ } ) ;
1428
+
1429
+ const figure = wrapper . find ( Figure ) ;
1430
+ expect ( figure . exists ( ) ) . toBe ( true ) ;
1431
+ expect ( figure . props ( 'anchor' ) ) . toBe ( metadata . anchor ) ;
1432
+ expect ( figure . contains ( Table ) ) . toBe ( true ) ;
1433
+
1434
+ const caption = figure . find ( FigureCaption ) ;
1435
+ expect ( caption . exists ( ) ) . toBe ( true ) ;
1436
+ expect ( caption . props ( 'title' ) ) . toBe ( metadata . title ) ;
1437
+ expect ( caption . props ( 'centered' ) ) . toBe ( false ) ;
1438
+ expect ( caption . contains ( 'p' ) ) . toBe ( true ) ;
1439
+ expect ( caption . text ( ) ) . toContain ( 'blah' ) ;
1440
+ } ) ;
1441
+
1418
1442
describe ( 'and column/row spanning' , ( ) => {
1419
1443
// <table>
1420
1444
// <tr>
0 commit comments