@@ -127,4 +127,75 @@ describe('Observable.fromEvent', function () {
127
127
128
128
send ( 'test' ) ;
129
129
} ) ;
130
- } ) ;
130
+
131
+ it ( 'should not fail if no event arguments are passed and the selector does not return' , function ( done ) {
132
+ var send ;
133
+ var obj = {
134
+ on : function ( name , handler ) {
135
+ send = handler ;
136
+ } ,
137
+ off : function ( ) {
138
+ }
139
+ } ;
140
+
141
+ function selector ( ) {
142
+ }
143
+
144
+ Observable . fromEvent ( obj , 'click' , selector ) . take ( 1 )
145
+ . subscribe ( function ( e ) {
146
+ expect ( e ) . toBeUndefined ( ) ;
147
+ } , function ( err ) {
148
+ done . fail ( 'should not be called' ) ;
149
+ } , done ) ;
150
+
151
+ send ( ) ;
152
+ } ) ;
153
+
154
+ it ( 'should return a value from the selector if no event arguments are passed' , function ( done ) {
155
+ var send ;
156
+ var obj = {
157
+ on : function ( name , handler ) {
158
+ send = handler ;
159
+ } ,
160
+ off : function ( ) {
161
+ }
162
+ } ;
163
+
164
+ function selector ( ) {
165
+ return 'no arguments' ;
166
+ }
167
+
168
+ Observable . fromEvent ( obj , 'click' , selector ) . take ( 1 )
169
+ . subscribe ( function ( e ) {
170
+ expect ( e ) . toBe ( 'no arguments' ) ;
171
+ } , function ( err ) {
172
+ done . fail ( 'should not be called' ) ;
173
+ } , done ) ;
174
+
175
+ send ( ) ;
176
+ } ) ;
177
+
178
+ it ( 'should pass multiple arguments to selector from event emitter' , function ( done ) {
179
+ var send ;
180
+ var obj = {
181
+ on : function ( name , handler ) {
182
+ send = handler ;
183
+ } ,
184
+ off : function ( ) {
185
+ }
186
+ } ;
187
+
188
+ function selector ( x , y , z ) {
189
+ return [ ] . slice . call ( arguments ) ;
190
+ }
191
+
192
+ Observable . fromEvent ( obj , 'click' , selector ) . take ( 1 )
193
+ . subscribe ( function ( e ) {
194
+ expect ( e ) . toEqual ( [ 1 , 2 , 3 ] ) ;
195
+ } , function ( err ) {
196
+ done . fail ( 'should not be called' ) ;
197
+ } , done ) ;
198
+
199
+ send ( 1 , 2 , 3 ) ;
200
+ } ) ;
201
+ } ) ;
0 commit comments