-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcomponent.test.js
41 lines (36 loc) · 1.07 KB
/
component.test.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
import Autoextra from './component'
import { mount, shallowMount } from '@vue/test-utils'
describe('Autoextra', () => {
it('should include a slot for ever item in the collection, plus one extra', done => {
const wrapper = mount(Autoextra, {
propsData: {
collection: [{
name: 'joe'
}]
},
scopedSlots: {
default: '<div><input type="text" v-model="props.item.name"/></div>'
}
})
wrapper.vm.$nextTick(() => {
expect(wrapper.findAll('input').length).toEqual(2)
expect(wrapper.findAll('input').at(0).element.value).toEqual('joe')
done()
})
})
it('should include yet another entry when editing the extra entry', done => {
const wrapper = mount(Autoextra, {
propsData: {
collection: []
},
scopedSlots: {
default: '<div><pre>{{props}}</pre><input type="text" v-model="props.item.name"/></div>'
}
})
wrapper.vm.$nextTick(() => {
const extraInput = wrapper.findAll('input').at(0)
extraInput.setValue('bar')
done()
})
})
})