Sha256: 3a1c38d36fee42f79ab67e4801972f367d568052c9ccd9085d5042770b27e38e
Contents?: true
Size: 1.38 KB
Versions: 3
Compression:
Stored size: 1.38 KB
Contents
describe "Joosy.Modules.Events", -> beforeEach -> class @TestEvents extends Joosy.Module @include Joosy.Modules.Events class @SubTestEvents extends @TestEvents @include Joosy.Modules.Events @box = new @TestEvents() @sub = new @SubTestEvents() it "should run callback once when the all listed events have occurred", -> callback = sinon.spy() @box.wait 'events list', callback @box.trigger 'events' expect(callback.callCount).toEqual 0 @box.trigger 'list' expect(callback.callCount).toEqual 1 @box.trigger 'events' expect(callback.callCount).toEqual 1 @box.trigger 'list' expect(callback.callCount).toEqual 1 it "should allow for binding and unbinding to events", -> callback = sinon.spy() @box.bind 'event', callback @box.trigger 'other-event' expect(callback.callCount).toEqual 0 @box.trigger 'event' expect(callback.callCount).toEqual 1 @box.trigger 'event' expect(callback.callCount).toEqual 2 @box.unbind 'other-event' @box.trigger 'event' expect(callback.callCount).toEqual 3 @box.unbind callback @box.trigger 'event' expect(callback.callCount).toEqual 3 it "should handle inheritance well", -> callback = sinon.spy() @sub.wait 'foo', callback expect(@sub.__oneShotEvents).toEqual [[['foo'], callback]] expect(@box.__oneShotEvents).toBeUndefined()
Version data entries
3 entries across 3 versions & 1 rubygems