1
1
import ComponentWithTransition from '~resources/components/component-with-transition.vue'
2
2
import TransitionStub from '~src/components/TransitionStub'
3
- import { mount } from '~vue- test-utils'
3
+ import { describeWithShallowAndMount } from '~resources/ test-utils'
4
4
5
- describe ( 'TransitionStub' , ( ) => {
5
+ describeWithShallowAndMount ( 'TransitionStub' , ( mountingMethod ) => {
6
6
it ( 'update synchronously when used as stubs for Transition' , ( ) => {
7
- const wrapper = mount ( ComponentWithTransition , {
7
+ const wrapper = mountingMethod ( ComponentWithTransition , {
8
8
stubs : {
9
9
'transition' : TransitionStub
10
10
}
@@ -14,6 +14,32 @@ describe('TransitionStub', () => {
14
14
expect ( wrapper . text ( ) ) . contains ( 'b' )
15
15
} )
16
16
17
+ it ( 'does not add v-leave class to children' , ( ) => {
18
+ const TestComponent = {
19
+ template : `
20
+ <div>
21
+ <transition name="expand">
22
+ <nav v-show="isShown" />
23
+ </transition>
24
+ <button @click="isShown = !isShown" />
25
+ </div>
26
+ ` ,
27
+ data : ( ) => ( {
28
+ isShown : false
29
+ } )
30
+ }
31
+ const wrapper = mountingMethod ( TestComponent , {
32
+ stubs : {
33
+ 'transition' : TransitionStub
34
+ }
35
+ } )
36
+ expect ( wrapper . find ( 'nav' ) . visible ( ) ) . to . equal ( false )
37
+ wrapper . find ( 'button' ) . trigger ( 'click' )
38
+ expect ( wrapper . find ( 'nav' ) . visible ( ) ) . to . equal ( true )
39
+ wrapper . find ( 'button' ) . trigger ( 'click' )
40
+ expect ( wrapper . find ( 'nav' ) . visible ( ) ) . to . equal ( false )
41
+ } )
42
+
17
43
it ( 'logs error when has multiple children' , ( ) => {
18
44
const TestComponent = {
19
45
template : `
@@ -22,7 +48,7 @@ describe('TransitionStub', () => {
22
48
}
23
49
const msg = '[vue-test-utils]: <transition> can only be used on a single element. Use <transition-group> for lists.'
24
50
const error = sinon . stub ( console , 'error' )
25
- mount ( TestComponent , {
51
+ mountingMethod ( TestComponent , {
26
52
stubs : {
27
53
'transition' : TransitionStub
28
54
}
@@ -47,7 +73,7 @@ describe('TransitionStub', () => {
47
73
}
48
74
}
49
75
}
50
- const wrapper = mount ( TestComponent , {
76
+ const wrapper = mountingMethod ( TestComponent , {
51
77
stubs : {
52
78
'transition' : TransitionStub
53
79
}
0 commit comments