|
6 | 6 | *
|
7 | 7 | * See https://swift.org/LICENSE.txt for license information
|
8 | 8 | * See https://swift.org/CONTRIBUTORS.txt for Swift project authors
|
9 |
| -*/ |
| 9 | + */ |
10 | 10 |
|
11 | 11 | import { mount } from '@vue/test-utils';
|
12 | 12 | import Card from '@/components/Card.vue';
|
13 | 13 | import { TopicRole } from '@/constants/roles';
|
14 | 14 | import TopicTypeIcon from '@/components/TopicTypeIcon.vue';
|
15 |
| -import TopicsLinkCardGridItem from '@/components/DocumentationTopic/TopicsLinkCardGridItem.vue'; |
| 15 | +import TopicsLinkCardGridItem, { |
| 16 | + ROLE_LINK_TEXT, |
| 17 | +} from '@/components/DocumentationTopic/TopicsLinkCardGridItem.vue'; |
16 | 18 |
|
17 | 19 | const defaultProps = {
|
18 | 20 | item: {
|
@@ -118,7 +120,29 @@ describe('TopicsLinkCardGridItem', () => {
|
118 | 120 | content: defaultProps.item.abstract,
|
119 | 121 | floatingStyle: true,
|
120 | 122 | size: 'large',
|
121 |
| - linkText: 'Visit page', |
| 123 | + linkText: ROLE_LINK_TEXT[TopicRole.article], |
122 | 124 | });
|
123 | 125 | });
|
| 126 | + |
| 127 | + it('renders different text for diff roles', () => { |
| 128 | + const wrapper = createWrapper({ |
| 129 | + propsData: { |
| 130 | + ...defaultProps, |
| 131 | + compact: false, |
| 132 | + item: { ...defaultProps.item, role: TopicRole.overview }, |
| 133 | + }, |
| 134 | + }); |
| 135 | + // overview |
| 136 | + const card = wrapper.find(Card); |
| 137 | + expect(card.props('linkText')).toBe(ROLE_LINK_TEXT[TopicRole.overview]); |
| 138 | + // collection |
| 139 | + wrapper.setProps({ item: { ...defaultProps.item, role: TopicRole.collection } }); |
| 140 | + expect(card.props('linkText')).toBe(ROLE_LINK_TEXT[TopicRole.collection]); |
| 141 | + // symbol |
| 142 | + wrapper.setProps({ item: { ...defaultProps.item, role: TopicRole.symbol } }); |
| 143 | + expect(card.props('linkText')).toBe(ROLE_LINK_TEXT[TopicRole.symbol]); |
| 144 | + // other |
| 145 | + wrapper.setProps({ item: { ...defaultProps.item, role: TopicRole.link } }); |
| 146 | + expect(card.props('linkText')).toBe('Learn more'); |
| 147 | + }); |
124 | 148 | });
|
0 commit comments