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')
1717require ( 'rxjs/add/operator/startWith' )
1818require ( 'rxjs/add/operator/scan' )
1919require ( 'rxjs/add/operator/pluck' )
20+ require ( 'rxjs/add/operator/merge' )
2021
2122const miniRx = {
2223 Observable,
@@ -141,6 +142,39 @@ test('v-stream directive (basic)', done => {
141142 } )
142143} )
143144
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+
144178test ( 'v-stream directive (with data)' , done => {
145179 const vm = new Vue ( {
146180 data : {
You can’t perform that action at this time.
0 commit comments