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' ;
@@ -15,6 +15,7 @@ import TopicTypeIcon from '@/components/TopicTypeIcon.vue';
15
15
import TopicsLinkCardGridItem , {
16
16
ROLE_LINK_TEXT ,
17
17
} from '@/components/DocumentationTopic/TopicsLinkCardGridItem.vue' ;
18
+ import ContentNode from 'docc-render/components/ContentNode.vue' ;
18
19
19
20
const defaultProps = {
20
21
item : {
@@ -54,12 +55,12 @@ describe('TopicsLinkCardGridItem', () => {
54
55
url : defaultProps . item . url ,
55
56
image : defaultProps . item . images [ 0 ] . reference ,
56
57
title : defaultProps . item . title ,
57
- content : [ ] , // compact items do not have content
58
58
floatingStyle : true ,
59
59
size : undefined ,
60
60
linkText : '' ,
61
61
} ) ;
62
62
expect ( wrapper . find ( '.reference-card-grid-item__image' ) . exists ( ) ) . toBe ( false ) ;
63
+ expect ( wrapper . find ( ContentNode ) . exists ( ) ) . toBe ( false ) ;
63
64
} ) ;
64
65
65
66
it ( 'renders a TopicsLinkCardGridItem, with an icon as a fallback' , ( ) => {
@@ -76,11 +77,11 @@ describe('TopicsLinkCardGridItem', () => {
76
77
url : defaultProps . item . url ,
77
78
image : null ,
78
79
title : defaultProps . item . title ,
79
- content : [ ] , // compact items do not have content
80
80
floatingStyle : true ,
81
81
size : undefined ,
82
82
linkText : '' ,
83
83
} ) ;
84
+ expect ( wrapper . find ( ContentNode ) . exists ( ) ) . toBe ( false ) ;
84
85
const imageWrapper = wrapper . find ( '.reference-card-grid-item__image' ) ;
85
86
expect ( imageWrapper . exists ( ) ) . toBe ( true ) ;
86
87
const icon = imageWrapper . find ( TopicTypeIcon ) ;
@@ -106,22 +107,24 @@ describe('TopicsLinkCardGridItem', () => {
106
107
expect ( wrapper . find ( TopicTypeIcon ) . props ( 'imageOverride' ) ) . toEqual ( iconRef ) ;
107
108
} ) ;
108
109
109
- it ( 'renders a TopicsLinkCardGridItem, in a none compact variant' , ( ) => {
110
+ it ( 'renders a TopicsLinkCardGridItem, in a none compact variant' , async ( ) => {
110
111
const wrapper = createWrapper ( {
111
112
propsData : {
112
113
...defaultProps ,
113
114
compact : false ,
114
115
} ,
115
116
} ) ;
116
- expect ( wrapper . find ( Card ) . props ( ) ) . toMatchObject ( {
117
+ await wrapper . vm . $nextTick ( ) ;
118
+ const card = wrapper . find ( Card ) ;
119
+ expect ( card . props ( ) ) . toMatchObject ( {
117
120
url : defaultProps . item . url ,
118
121
image : defaultProps . item . images [ 0 ] . reference ,
119
122
title : defaultProps . item . title ,
120
- content : defaultProps . item . abstract ,
121
123
floatingStyle : true ,
122
124
size : 'large' ,
123
125
linkText : ROLE_LINK_TEXT [ TopicRole . article ] ,
124
126
} ) ;
127
+ expect ( wrapper . find ( ContentNode ) . props ( 'content' ) ) . toBe ( defaultProps . item . abstract ) ;
125
128
} ) ;
126
129
127
130
it ( 'renders different text for diff roles' , ( ) => {
0 commit comments