-
Notifications
You must be signed in to change notification settings - Fork 27.4k
feat(ngMock.$componentController): add helper to instantiate controllers for components #13711
feat(ngMock.$componentController): add helper to instantiate controllers for components #13711
Conversation
7a5ddb4
to
273e7dc
Compare
expect(ctrl).toEqual({$scope: $scope, a: 'A', b: 'B', x: 'X', y: 'Y' }); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add a test with controller: 'TestController as test'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you like but the implementation is just proxying to $controller
anyway so it doesn't test any new paths.
Wouldn't it be nice to have that for plain directives, too? |
There will be some slight inconsistency between using |
@Narretz - it is much more complicated to do it for plain directives because we don't actually call the directive factory function until the directive is matched in some HTML. This means that the controller is not easily available. Components are simpler because the controller is not wrapped in a factory function. |
@gkalpak this is also true of |
2d031d6
to
0fa49cd
Compare
…ers for components Closes angular#13683
0fa49cd
to
ca376fa
Compare
@petebacondarwin, true, but things are more explicit there. You are are the one passing the argument to I wouldn't go to great lengths trying to "fix" this. If there's no easy fix (e.g. extracting the controller name and ignoring the alias or something), I would at least document that when using No biggie anyway - it only affects test code. Feel free to leave as is, if you think it's OK. |
@gkalpak - OK, I see what you mean. But since this is for people testing controllers that (hopefully) they have actually written, then it shouldn't be too surprising! |
Actually in light of the latest discussions about |
…ers for components Closes angular#13683
Now it LRGTM ('R' for "really") 😃 |
Closes #13683