@@ -20,34 +20,48 @@ describe('events', () => {
2020 var object = null
2121
2222 beforeEach ( ( ) => {
23- object = sinon . stub ( {
23+ // Note: es6 class instances have non-enumerable prototype properties.
24+ function FB ( ) { } ;
25+ FB . prototype = {
26+ onPrototypeBar ( ) { }
27+ }
28+ object = new FB ( )
29+ Object . assign ( object , {
2430 onFoo : ( ) => { } ,
2531 onFooBar : ( ) => { } ,
26- foo : ( ) => { } ,
27- bar : ( ) => { }
32+ foo : ( ) => { }
2833 } )
34+
2935 emitter . bind ( object )
3036 } )
3137
3238 it ( 'should register all "on" methods to events' , ( ) => {
39+ sinon . spy ( object , 'onFoo' )
3340 emitter . emit ( 'foo' )
3441 expect ( object . onFoo ) . to . have . been . called
3542
43+ sinon . spy ( object , 'onFooBar' )
3644 emitter . emit ( 'foo_bar' )
3745 expect ( object . onFooBar ) . to . have . been . called
3846
47+ sinon . spy ( object , 'onPrototypeBar' )
48+ emitter . emit ( 'prototype_bar' )
49+ expect ( object . onPrototypeBar ) . to . have . been . called
50+
51+ sinon . spy ( object , 'foo' )
3952 expect ( object . foo ) . not . to . have . been . called
40- expect ( object . bar ) . not . to . have . been . called
4153 } )
4254
4355 it ( 'should bind methods to the owner object' , ( ) => {
56+ sinon . spy ( object , 'foo' )
57+ sinon . spy ( object , 'onFoo' )
58+ sinon . spy ( object , 'onFooBar' )
4459 emitter . emit ( 'foo' )
4560 emitter . emit ( 'foo_bar' )
4661
4762 expect ( object . onFoo ) . to . have . always . been . calledOn ( object )
4863 expect ( object . onFooBar ) . to . have . always . been . calledOn ( object )
4964 expect ( object . foo ) . not . to . have . been . called
50- expect ( object . bar ) . not . to . have . been . called
5165 } )
5266 } )
5367
0 commit comments