File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ require('rxjs/add/operator/map')
17
17
require ( 'rxjs/add/operator/startWith' )
18
18
require ( 'rxjs/add/operator/scan' )
19
19
require ( 'rxjs/add/operator/pluck' )
20
+ require ( 'rxjs/add/operator/merge' )
20
21
21
22
const miniRx = {
22
23
Observable,
@@ -141,6 +142,39 @@ test('v-stream directive (basic)', done => {
141
142
} )
142
143
} )
143
144
145
+ test ( 'v-stream directive (with .native modify)' , done => {
146
+ const vm = new Vue ( {
147
+ template : `
148
+ <div>
149
+ <span class="count">{{ count }}</span>
150
+ <my-button v-stream:click.native="clickNative$">+</my-button>
151
+ <my-button v-stream:click="click$">-</my-button>
152
+ </div>
153
+ ` ,
154
+ components : {
155
+ myButton : {
156
+ template : '<button>MyButton</button>'
157
+ }
158
+ } ,
159
+ domStreams : [ 'clickNative$' , 'click$' ] ,
160
+ subscriptions ( ) {
161
+ return {
162
+ count : this . click$ . map ( ( ) => - 1 )
163
+ . merge ( this . clickNative$ . map ( ( ) => 1 ) )
164
+ . startWith ( 0 )
165
+ . scan ( ( total , change ) => total + change )
166
+ }
167
+ }
168
+ } ) . $mount ( )
169
+
170
+ expect ( vm . $el . querySelector ( 'span' ) . textContent ) . toBe ( '0' )
171
+ click ( vm . $el . querySelector ( 'button' ) )
172
+ nextTick ( ( ) => {
173
+ expect ( vm . $el . querySelector ( 'span' ) . textContent ) . toBe ( '1' )
174
+ done ( )
175
+ } )
176
+ } )
177
+
144
178
test ( 'v-stream directive (with data)' , done => {
145
179
const vm = new Vue ( {
146
180
data : {
You can’t perform that action at this time.
0 commit comments