Skip to content

Commit 67721eb

Browse files
committed
fix(test): make test in .native modifier more accurate
1 parent 54f4cc1 commit 67721eb

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

test/test.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ require('rxjs/add/operator/startWith')
1818
require('rxjs/add/operator/scan')
1919
require('rxjs/add/operator/pluck')
2020
require('rxjs/add/operator/merge')
21+
require('rxjs/add/operator/filter')
2122

2223
const miniRx = {
2324
Observable,
@@ -147,8 +148,8 @@ test('v-stream directive (with .native modify)', done => {
147148
template: `
148149
<div>
149150
<span class="count">{{ count }}</span>
150-
<my-button v-stream:click.native="clickNative$">+</my-button>
151-
<my-button v-stream:click="click$">-</my-button>
151+
<my-button id="btn-native" v-stream:click.native="clickNative$">+</my-button>
152+
<my-button id="btn" v-stream:click="click$">-</my-button>
152153
</div>
153154
`,
154155
components: {
@@ -159,16 +160,20 @@ test('v-stream directive (with .native modify)', done => {
159160
domStreams: ['clickNative$', 'click$'],
160161
subscriptions () {
161162
return {
162-
count: this.click$.map(() => -1)
163-
.merge(this.clickNative$.map(() => 1))
163+
count: this.clickNative$
164+
.filter(e => e.event.target && e.event.target.id === 'btn-native')
165+
.map(() => 1)
166+
.merge(this.click$.map(() => -1))
167+
.merge()
164168
.startWith(0)
165169
.scan((total, change) => total + change)
166170
}
167171
}
168172
}).$mount()
169173

170174
expect(vm.$el.querySelector('span').textContent).toBe('0')
171-
click(vm.$el.querySelector('button'))
175+
click(vm.$el.querySelector('#btn-native'))
176+
click(vm.$el.querySelector('#btn'))
172177
nextTick(() => {
173178
expect(vm.$el.querySelector('span').textContent).toBe('1')
174179
done()

0 commit comments

Comments
 (0)