Skip to content

Commit b04f493

Browse files
committed
[rdar://30234820] fix: address feedback
1 parent f81e35c commit b04f493

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

src/components/ContentNode/Caption.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export default {
3333
},
3434
tag: {
3535
type: String,
36-
required: false,
37-
default: () => 'caption',
36+
required: true,
37+
validator: v => new Set(['caption', 'figcaption']).has(v),
3838
},
3939
},
4040
};
@@ -44,7 +44,7 @@ export default {
4444
@import 'docc-render/styles/_core.scss';
4545
4646
.caption {
47-
@include font-styles(documentation-figcaption);
47+
@include font-styles(documentation-caption);
4848
4949
&:last-child {
5050
margin-top: var(--spacing-stacked-margin-large);
@@ -59,7 +59,7 @@ export default {
5959
display: inline-block;
6060
}
6161
62-
caption {
63-
margin: 1rem 0;
62+
caption + * {
63+
margin-top: 1rem;
6464
}
6565
</style>

tests/unit/components/ContentNode.spec.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,29 @@ describe('ContentNode', () => {
112112
expect(codeListing.props('content')).toEqual(listing.code);
113113
expect(codeListing.isEmpty()).toBe(true);
114114
});
115+
116+
it('renders a `Figure`/`Caption` 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(Caption);
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+
});
115138
});
116139

117140
describe('with type="endpointExample"', () => {
@@ -753,7 +776,7 @@ describe('ContentNode', () => {
753776
`);
754777
});
755778

756-
it('renders a `FigureCaption` before the image, if it has a title', () => {
779+
it('renders a `Caption` before the image, if it has a title', () => {
757780
const metadata = {
758781
title: 'foo',
759782
abstract: [{
@@ -776,7 +799,7 @@ describe('ContentNode', () => {
776799
`);
777800
});
778801

779-
it('renders no `FigureCaption`, if there is a `title`, but no `abstract`', () => {
802+
it('renders no `Caption`, if there is a `title`, but no `abstract`', () => {
780803
const metadata = {
781804
postTitle: true,
782805
title: 'Foo',

0 commit comments

Comments
 (0)