forked from vuejs/vue-test-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransitionGroupStub.spec.js
61 lines (58 loc) · 1.71 KB
/
TransitionGroupStub.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import ComponentWithTransitionGroup from '~resources/components/component-with-transition-group.vue'
import { TransitionGroupStub } from '~vue/test-utils'
import { describeWithShallowAndMount, vueVersion } from '~resources/utils'
import { itDoNotRunIf } from 'conditional-specs'
describeWithShallowAndMount('TransitionGroupStub', mountingMethod => {
it('update synchronously when used as stubs for Transition', () => {
const wrapper = mountingMethod(ComponentWithTransitionGroup, {
stubs: {
'transition-group': TransitionGroupStub
}
})
expect(wrapper.text()).contains('a')
wrapper.setData({ a: 'b' })
expect(wrapper.text()).contains('b')
})
itDoNotRunIf(
vueVersion < 2.5,
'does not stub TransitionGroup, but applies synchronously in Vue > 2.5.18',
() => {
const wrapper = mountingMethod(ComponentWithTransitionGroup)
expect(wrapper.find(TransitionGroupStub).exists()).to.equal(false)
expect(wrapper.text()).contains('a')
wrapper.setData({ a: 'b' })
expect(wrapper.text()).contains('b')
}
)
it('updates watchers', () => {
const TestComponent = {
data: () => ({
someWatchedData: null,
someData: null
}),
watch: {
someWatchedData(newData) {
this.someData = newData
}
},
template: `
<transition-group
mode="out-in"
class="body"
tag="div"
>
{{someData}}
</transition-group>
`
}
const wrapper = mountingMethod(TestComponent, {
stubs: {
'transition-group': TransitionGroupStub
}
})
wrapper.setData({
someWatchedData: 'some data'
})
expect(wrapper.html()).contains('some data')
})
})