Skip to content

Commit a7b7c83

Browse files
committed
[Tests] Reimplement skipped tests
1 parent c88326b commit a7b7c83

File tree

5 files changed

+76
-7
lines changed

5 files changed

+76
-7
lines changed

test/resources/components/component-with-events.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
22
<div>
33
<button class="click" @click="clickHandler" id="button" />
4+
<div @click="toggleActive" v-bind:class="{ toggle: true, active: isActive }" />
45
<input class="keydown" type="text" @keydown="keydownHandler" />
56
<input class="keydown-enter" type="text" @keydown.enter="keydownHandler" />
67
</div>
@@ -18,6 +19,16 @@
1819
type: Function,
1920
default: () => {}
2021
}
22+
},
23+
data () {
24+
return {
25+
isActive: false
26+
}
27+
},
28+
methods: {
29+
toggleActive () {
30+
this.isActive = !this.isActive
31+
}
2132
}
2233
}
2334
</script>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<template>
2+
<div>
3+
<AComponent v-for="item in items" :key="item.id" />
4+
</div>
5+
</template>
6+
7+
<script>
8+
import AComponent from './component.vue'
9+
10+
export default {
11+
name: 'component-with-v-for',
12+
components: {
13+
AComponent
14+
},
15+
props: ['items']
16+
}
17+
</script>

test/unit/specs/mount/find.spec.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { compileToFunctions } from 'vue-template-compiler'
22
import mount from '../../../../src/mount'
33
import ComponentWithChildComponent from '../../../resources/components/component-with-child-component.vue'
44
import ComponentWithoutName from '../../../resources/components/component-without-name.vue'
5+
import ComponentWithSlots from '../../../resources/components/component-with-slots.vue'
6+
import ComponentWithVFor from '../../../resources/components/component-with-v-for.vue'
57
import Component from '../../../resources/components/component.vue'
68
import Wrapper from '../../../../src/Wrapper'
79

@@ -24,7 +26,13 @@ describe('find', () => {
2426
expect(wrapper.find('div')).to.be.instanceOf(Wrapper)
2527
})
2628

27-
it.skip('returns an array of Wrapper of elements matching class selector passed if they are declared inside a slot', () => {
29+
it('returns an array of Wrapper of elements matching class selector passed if they are declared inside a slot', () => {
30+
const wrapper = mount(ComponentWithSlots, {
31+
slots: {
32+
default: '<div class="foo"></div>'
33+
}
34+
})
35+
expect(wrapper.find('.foo')).to.be.instanceOf(Wrapper)
2836
})
2937

3038
it('returns Wrapper of elements matching id selector passed', () => {
@@ -69,10 +77,17 @@ describe('find', () => {
6977
expect(wrapper.find(Component)).to.be.instanceOf(Wrapper)
7078
})
7179

72-
it.skip('returns correct number of Vue Wrapper when component has a v-for', () => {
80+
it('returns correct number of Vue Wrapper when component has a v-for', () => {
81+
const items = [{ id: 1 }, { id: 2 }, { id: 3 }]
82+
const wrapper = mount(ComponentWithVFor, { propsData: { items }})
83+
expect(wrapper.find(Component)).to.be.instanceOf(Wrapper)
7384
})
7485

75-
it.skip('returns array of VueWrappers of Vue Components matching component if component name in parent is different to filename', () => {
86+
it('returns array of VueWrappers of Vue Components matching component if component name in parent is different to filename', () => {
87+
// same test as above, but good to be explicit
88+
const wrapper = mount(ComponentWithChildComponent)
89+
const div = wrapper.find('span')
90+
expect(div.find(Component)).to.be.instanceOf(Wrapper)
7691
})
7792

7893
it('returns Wrapper of Vue Component matching component using Wrapper as reference', () => {

test/unit/specs/mount/findAll.spec.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { compileToFunctions } from 'vue-template-compiler'
22
import mount from '../../../../src/mount'
33
import ComponentWithChildComponent from '../../../resources/components/component-with-child-component.vue'
44
import ComponentWithoutName from '../../../resources/components/component-without-name.vue'
5+
import ComponentWithSlots from '../../../resources/components/component-with-slots.vue'
6+
import ComponentWithVFor from '../../../resources/components/component-with-v-for.vue'
57
import Component from '../../../resources/components/component.vue'
68
import WrapperArray from '../../../../src/WrapperArray'
79

@@ -30,7 +32,15 @@ describe('findAll', () => {
3032
expect(divArr.length).to.equal(1)
3133
})
3234

33-
it.skip('returns an array of Wrapper of elements matching class selector passed if they are declared inside a slot', () => {
35+
it('returns an array of Wrapper of elements matching class selector passed if they are declared inside a slot', () => {
36+
const wrapper = mount(ComponentWithSlots, {
37+
slots: {
38+
default: '<div class="foo"><div class="foo"></div></div>'
39+
}
40+
})
41+
const fooArr = wrapper.findAll('.foo')
42+
expect(fooArr).to.be.instanceOf(WrapperArray)
43+
expect(fooArr.length).to.equal(2)
3444
})
3545

3646
it('returns an array of Wrappers of elements matching id selector passed', () => {
@@ -92,13 +102,24 @@ describe('findAll', () => {
92102
expect(componentArr.length).to.equal(1)
93103
})
94104

95-
it.skip('returns correct number of Vue Wrapper when component has a v-for', () => {
105+
it('returns correct number of Vue Wrapper when component has a v-for', () => {
106+
const items = [{ id: 1 }, { id: 2 }, { id: 3 }]
107+
const wrapper = mount(ComponentWithVFor, { propsData: { items }})
108+
const componentArray = wrapper.findAll(Component)
109+
expect(componentArray).to.be.instanceOf(WrapperArray)
110+
expect(componentArray.length).to.equal(items.length)
96111
})
97112

98-
it.skip('returns array of VueWrappers of Vue Components matching component if component name in parent is different to filename', () => {
113+
it('returns array of VueWrappers of Vue Components matching component if component name in parent is different to filename', () => {
114+
const wrapper = mount(ComponentWithChildComponent)
115+
const div = wrapper.findAll('span').at(0)
116+
const componentArr = div.findAll(Component)
117+
expect(componentArr).to.be.instanceOf(WrapperArray)
118+
expect(componentArr.length).to.equal(1)
99119
})
100120

101121
it('returns an array of VueWrappers of Vue Components matching component using Wrapper as reference', () => {
122+
// same test as above, but good to be explicit
102123
const wrapper = mount(ComponentWithChildComponent)
103124
const div = wrapper.findAll('span').at(0)
104125
const componentArr = div.findAll(Component)

test/unit/specs/mount/trigger.spec.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ describe('trigger', () => {
3333
expect(keydownHandler.calledOnce).to.equal(true)
3434
})
3535

36-
it.skip('causes DOM to update after clickHandler method that changes components data is called', () => {
36+
it('causes DOM to update after clickHandler method that changes components data is called', () => {
37+
const wrapper = mount(ComponentWithEvents)
38+
const toggle = wrapper.find('.toggle')
39+
expect(toggle.hasClass('active')).to.equal(false)
40+
toggle.trigger('click')
41+
expect(toggle.hasClass('active')).to.equal(true)
3742
})
3843

3944
it('throws an error if type is not a string', () => {

0 commit comments

Comments
 (0)