beCodeMyFriend / Cuore.js

Other
34 stars 13 forks source link

testing collaboration handler - component #10

Closed hell03610 closed 12 years ago

hell03610 commented 12 years ago

When handler has logic and it's tested, it would be nice to test that a component uses that handler for some event, instead of dispatching the event and testing again handler and component.

Testing collaboration nowadays (breaking some rules): it("uses LoginHandler to handle the login", function() { var button = new LoginButton('name','key'); var handlers = button.handlerSet.handlersForEvent['LoginService_login_EXECUTED']; expect(handlers[0] instanceof LoginHandler); });

Suggested test/api: it("uses LoginHandler to handle the login", function() { var button = new LoginButton('name','key'); var handlers = button.getHandlersFor('LoginService_login_EXECUTED'); expect(handlers[0] instanceof LoginHandler); });