Skip to content

test(v-stream): ensure the data gets passed correctly also on custom component #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,23 @@ test('v-stream directive (with .stop, .prevent modify)', done => {
})

test('v-stream directive (with data)', done => {
const customButton = {
name: 'custom-button',
template: `<button id="custom-button" @click="$emit('click-custom')"><slot/></button>`
}

const vm = new Vue({
components: {
customButton
},
data: {
delta: -1
},
template: `
<div>
<span class="count">{{ count }}</span>
<button v-stream:click="{ subject: click$, data: delta }">+</button>
<button id="native-button" v-stream:click="{ subject: click$, data: delta }">+</button>
<custom-button v-stream:click-custom="{ subject: click$, data: delta }">+</custom-button>
</div>
`,
domStreams: ['click$'],
Expand All @@ -256,12 +265,12 @@ test('v-stream directive (with data)', done => {
}).$mount()

expect(vm.$el.querySelector('span').textContent).toBe('0')
click(vm.$el.querySelector('button'))
click(vm.$el.querySelector('#custom-button'))
nextTick(() => {
expect(vm.$el.querySelector('span').textContent).toBe('-1')
vm.delta = 1
nextTick(() => {
click(vm.$el.querySelector('button'))
click(vm.$el.querySelector('#native-button'))
nextTick(() => {
expect(vm.$el.querySelector('span').textContent).toBe('0')
done()
Expand Down