Skip to content

Commit b610443

Browse files
briwaregou
authored andcommitted
test(v-stream): ensure the data gets passed correctly also on custom component (#108)
* test(v-stream): make sure that it passes the value correctly also on custom component * refactor(v-stream/test): combine them to one because it's redundant? * refactor(v-stream/test): use a different event name
1 parent f7b72b6 commit b610443

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

test/test.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,23 @@ test('v-stream directive (with .stop, .prevent modify)', done => {
233233
})
234234

235235
test('v-stream directive (with data)', done => {
236+
const customButton = {
237+
name: 'custom-button',
238+
template: `<button id="custom-button" @click="$emit('click-custom')"><slot/></button>`
239+
}
240+
236241
const vm = new Vue({
242+
components: {
243+
customButton
244+
},
237245
data: {
238246
delta: -1
239247
},
240248
template: `
241249
<div>
242250
<span class="count">{{ count }}</span>
243-
<button v-stream:click="{ subject: click$, data: delta }">+</button>
251+
<button id="native-button" v-stream:click="{ subject: click$, data: delta }">+</button>
252+
<custom-button v-stream:click-custom="{ subject: click$, data: delta }">+</custom-button>
244253
</div>
245254
`,
246255
domStreams: ['click$'],
@@ -256,12 +265,12 @@ test('v-stream directive (with data)', done => {
256265
}).$mount()
257266

258267
expect(vm.$el.querySelector('span').textContent).toBe('0')
259-
click(vm.$el.querySelector('button'))
268+
click(vm.$el.querySelector('#custom-button'))
260269
nextTick(() => {
261270
expect(vm.$el.querySelector('span').textContent).toBe('-1')
262271
vm.delta = 1
263272
nextTick(() => {
264-
click(vm.$el.querySelector('button'))
273+
click(vm.$el.querySelector('#native-button'))
265274
nextTick(() => {
266275
expect(vm.$el.querySelector('span').textContent).toBe('0')
267276
done()

0 commit comments

Comments
 (0)