@@ -156,6 +156,22 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => {
156
156
expect ( wrapper . html ( ) ) . to . contain ( '<child-stub prop="a" attr="hello"' )
157
157
} )
158
158
159
+ itDoNotRunIf (
160
+ vueVersion < 2.2 , // $props does not exist in Vue < 2.2
161
+ 'renders stubs classes' , ( ) => {
162
+ const TestComponent = {
163
+ template : `<child :class="classA" class="b" />` ,
164
+ data : ( ) => ( {
165
+ 'classA' : 'a'
166
+ } ) ,
167
+ components : {
168
+ child : { template : '<div />' }
169
+ }
170
+ }
171
+ const wrapper = shallowMount ( TestComponent )
172
+ expect ( wrapper . html ( ) ) . to . contain ( '<child-stub class="b a"' )
173
+ } )
174
+
159
175
it ( 'renders stubs props for functional components' , ( ) => {
160
176
const TestComponent = {
161
177
template : `<child :prop="propA" attr="hello" />` ,
@@ -173,6 +189,41 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => {
173
189
expect ( wrapper . html ( ) ) . to . contain ( '<child-stub prop="a" attr="hello"' )
174
190
} )
175
191
192
+ it ( 'renders classes for functional components' , ( ) => {
193
+ const components = {
194
+ Child : {
195
+ functional : true
196
+ }
197
+ }
198
+ const TestComponent = {
199
+ template : `<child :class="classA" class="b" />` ,
200
+ data : ( ) => ( {
201
+ 'classA' : 'a'
202
+ } ) ,
203
+ components
204
+ }
205
+ const wrapper = shallowMount ( TestComponent )
206
+ expect ( wrapper . html ( ) ) . to . contain ( '<child-stub class="b a"' )
207
+ const TestComponent2 = {
208
+ template : `<child :class="classA"/>` ,
209
+ data : ( ) => ( {
210
+ 'classA' : 'a'
211
+ } ) ,
212
+ components
213
+ }
214
+ const wrapper2 = shallowMount ( TestComponent2 )
215
+ expect ( wrapper2 . html ( ) ) . to . contain ( '<child-stub class="a"' )
216
+ const TestComponent3 = {
217
+ template : `<child class="b" />` ,
218
+ data : ( ) => ( {
219
+ 'classA' : 'a'
220
+ } ) ,
221
+ components
222
+ }
223
+ const wrapper3 = shallowMount ( TestComponent3 )
224
+ expect ( wrapper3 . html ( ) ) . to . contain ( '<child-stub class="b"' )
225
+ } )
226
+
176
227
itDoNotRunIf ( vueVersion < 2.1 , 'handles recursive components' , ( ) => {
177
228
const TestComponent = {
178
229
template : `
0 commit comments