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);
});
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); });