File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,14 @@ function createMockSocketObject () {
3232 } else {
3333 delete this . _listeners [ ev ] ;
3434 }
35- }
35+ } ,
36+ removeAllListeners : function ( ev ) {
37+ if ( ev ) {
38+ delete this . _listeners [ ev ] ;
39+ } else {
40+ this . _listeners = { } ;
41+ }
42+ } ,
3643 } ;
3744
3845 return socket ;
Original file line number Diff line number Diff line change @@ -121,6 +121,31 @@ describe('socketFactory', function () {
121121 } ) ;
122122
123123
124+ describe ( '#removeAllListeners' , function ( ) {
125+
126+ it ( 'should not call after removing listeners for an event' , function ( ) {
127+ socket . on ( 'event' , spy ) ;
128+ socket . removeAllListeners ( 'event' ) ;
129+
130+ mockIoSocket . emit ( 'event' ) ;
131+
132+ expect ( $browser . deferredFns . length ) . toBe ( 0 ) ;
133+ } ) ;
134+
135+ it ( 'should not call after removing all listeners' , function ( ) {
136+ socket . on ( 'event' , spy ) ;
137+ socket . on ( 'event2' , spy ) ;
138+ socket . removeAllListeners ( ) ;
139+
140+ mockIoSocket . emit ( 'event' ) ;
141+ mockIoSocket . emit ( 'event2' ) ;
142+
143+ expect ( $browser . deferredFns . length ) . toBe ( 0 ) ;
144+ } ) ;
145+
146+ } ) ;
147+
148+
124149 describe ( '#forward' , function ( ) {
125150
126151 it ( 'should forward events' , function ( ) {
You can’t perform that action at this time.
0 commit comments