aboutsummaryrefslogtreecommitdiffstats
path: root/test/service/formFactorySpec.js
diff options
context:
space:
mode:
authorVojta Jina2011-11-29 21:51:59 -0800
committerVojta Jina2012-01-23 11:05:36 -0800
commit992c790f0786fa45c1cc3710f29bf49c7c322ba7 (patch)
tree581d06ea9ba275a14d5891d83b2df03f9930bd45 /test/service/formFactorySpec.js
parentf5343c9fd3c7cd0fefdb4d71d2b579dbae998d6a (diff)
downloadangular.js-992c790f0786fa45c1cc3710f29bf49c7c322ba7.tar.bz2
refactor(scope): separate controller from scope
Controller is standalone object, created using "new" operator, not messed up with scope anymore. Instead, related scope is injected as $scope. See design proposal: https://docs.google.com/document/pub?id=1SsgVj17ec6tnZEX3ugsvg0rVVR11wTso5Md-RdEmC0k Closes #321 Closes #425 Breaks controller methods are not exported to scope automatically Breaks Scope#$new() does not take controller as argument anymore
Diffstat (limited to 'test/service/formFactorySpec.js')
-rw-r--r--test/service/formFactorySpec.js22
1 files changed, 9 insertions, 13 deletions
diff --git a/test/service/formFactorySpec.js b/test/service/formFactorySpec.js
index fbe601c6..1a23aa49 100644
--- a/test/service/formFactorySpec.js
+++ b/test/service/formFactorySpec.js
@@ -13,23 +13,24 @@ describe('$formFactory', function() {
var scope;
var log;
- function WidgetCtrl($formFactory){
- this.$formFactory = $formFactory;
+ function WidgetCtrl($formFactory, $scope) {
log += '<init>';
- this.$render = function() {
+ $scope.$render = function() {
log += '$render();';
};
- this.$on('$validate', function(e){
+ $scope.$on('$validate', function(e){
log += '$validate();';
});
+
+ this.$formFactory = $formFactory;
}
- WidgetCtrl.$inject = ['$formFactory'];
+ WidgetCtrl.$inject = ['$formFactory', '$scope'];
WidgetCtrl.prototype = {
- getFormFactory: function() {
- return this.$formFactory;
- }
+ getFormFactory: function() {
+ return this.$formFactory;
+ }
};
beforeEach(inject(function($rootScope, $formFactory) {
@@ -70,11 +71,6 @@ describe('$formFactory', function() {
expect(widget.$modelValue).toEqual('xyz');
}));
-
-
- it('should have controller prototype methods', inject(function($rootScope, $formFactory) {
- expect(widget.getFormFactory()).toEqual($formFactory);
- }));
});