Skip to content

Commit 3dce0b8

Browse files
tarunamasaTarun Amasa
andauthored
Framework Name Links In Body Styling (#371) 94293647
* added fix inside topicslink by adding another conditional that checks the topic.role, passes all tests * wrote tests for topic role fitting eslint guidelines * r[94293647] Used feedback from Marina + Marcus on updating test cases * "Added comment to topislinkblock describing that Framework name links should not be code voice" Co-authored-by: Tarun Amasa <“[email protected]”>
1 parent 30b6ea7 commit 3dce0b8

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/components/DocumentationTopic/TopicsLinkBlock.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
</template>
6060

6161
<script>
62+
import { TopicRole } from 'docc-render/constants/roles';
6263
import { buildUrl } from 'docc-render/utils/url-helper';
6364
import Badge from 'docc-render/components/Badge.vue';
6465
import WordBreak from 'docc-render/components/WordBreak.vue';
@@ -179,6 +180,8 @@ export default {
179180
if (topic.titleStyle === TitleStyles.title) {
180181
return topic.ideTitle ? 'span' : 'code';
181182
}
183+
// Framework name links should not be code voice
184+
if (topic.role && topic.role === TopicRole.collection) return 'span';
182185
183186
switch (topic.kind) {
184187
case TopicKind.symbol:

tests/unit/components/DocumentationTopic/TopicsLinkBlock.spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { shallowMount, RouterLinkStub } from '@vue/test-utils';
1212
import TopicsLinkBlock from 'docc-render/components/DocumentationTopic/TopicsLinkBlock.vue';
1313
import { ChangeNames } from 'docc-render/constants/Changes';
1414
import { multipleLinesClass } from 'docc-render/constants/multipleLines';
15+
import { TopicRole } from 'docc-render/constants/roles';
1516

1617
const {
1718
ReferenceType,
@@ -140,6 +141,28 @@ describe('TopicsLinkBlock', () => {
140141
expect(wordBreak.text()).toBe(propsData.topic.title);
141142
});
142143

144+
it('renders a `WordBreak` using <span> tag for Framework name links in Topic that have role collection', () => {
145+
wrapper.setProps({
146+
topic: {
147+
...propsData.topic,
148+
role: TopicRole.collection,
149+
kind: TopicKind.symbol,
150+
},
151+
});
152+
const wordBreak = wrapper.find('.link').find(WordBreak);
153+
expect(wordBreak.exists()).toBe(true);
154+
expect(wordBreak.attributes('tag')).toBe('span');
155+
expect(wordBreak.text()).toBe(propsData.topic.title);
156+
});
157+
158+
it('renders a `WordBreak` using <code> tag for Framework name links in Topic that do NOT have role collection', () => {
159+
wrapper.setProps({ topic: { ...propsData.topic, kind: TopicKind.symbol } });
160+
const wordBreak = wrapper.find('.link').find(WordBreak);
161+
expect(wordBreak.exists()).toBe(true);
162+
expect(wordBreak.attributes('tag')).toBe('code');
163+
expect(wordBreak.text()).toBe(propsData.topic.title);
164+
});
165+
143166
it('renders a `WordBreak` using <code> tag for links with a titleStyle == title and no ideTitle', () => {
144167
wrapper.setProps({ topic: { ...propsData.topic, titleStyle: 'title' } });
145168
const wordBreak = wrapper.find('.link').find(WordBreak);

0 commit comments

Comments
 (0)