aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng/directive/inputSpec.js
diff options
context:
space:
mode:
authorMisko Hevery2012-06-06 13:58:10 -0700
committerIgor Minar2012-06-08 15:50:13 -0700
commitc3a41ff9fefe894663c4d4f40a83794521deb14f (patch)
treeb44037cfb0089cfea42f253b6ad1a09ccb7e2d86 /test/ng/directive/inputSpec.js
parent5c95b8cccc0d72f7ca3afb1162b9528c1222eb3c (diff)
downloadangular.js-c3a41ff9fefe894663c4d4f40a83794521deb14f.tar.bz2
feat($compile): simplify isolate scope bindings
Changed the isolate scope binding options to: - @attr - attribute binding (including interpolation) - =model - by-directional model binding - &expr - expression execution binding This change simplifies the terminology as well as number of choices available to the developer. It also supports local name aliasing from the parent. BREAKING CHANGE: isolate scope bindings definition has changed and the inject option for the directive controller injection was removed. To migrate the code follow the example below: Before: scope: { myAttr: 'attribute', myBind: 'bind', myExpression: 'expression', myEval: 'evaluate', myAccessor: 'accessor' } After: scope: { myAttr: '@', myBind: '@', myExpression: '&', // myEval - usually not useful, but in cases where the expression is assignable, you can use '=' myAccessor: '=' // in directive's template change myAccessor() to myAccessor } The removed `inject` wasn't generaly useful for directives so there should be no code using it.
Diffstat (limited to 'test/ng/directive/inputSpec.js')
-rw-r--r--test/ng/directive/inputSpec.js29
1 files changed, 22 insertions, 7 deletions
diff --git a/test/ng/directive/inputSpec.js b/test/ng/directive/inputSpec.js
index d7ca7aea..3b511011 100644
--- a/test/ng/directive/inputSpec.js
+++ b/test/ng/directive/inputSpec.js
@@ -4,7 +4,7 @@ describe('NgModelController', function() {
var ctrl, scope, ngModelAccessor, element, parentFormCtrl;
beforeEach(inject(function($rootScope, $controller) {
- var attrs = {name: 'testAlias'};
+ var attrs = {name: 'testAlias', ngModel: 'value'};
parentFormCtrl = {
$setValidity: jasmine.createSpy('$setValidity'),
@@ -17,12 +17,7 @@ describe('NgModelController', function() {
scope = $rootScope;
ngModelAccessor = jasmine.createSpy('ngModel accessor');
ctrl = $controller(NgModelController, {
- $scope: scope, $element: element.find('input'), ngModel: ngModelAccessor, $attrs: attrs
- });
- // mock accessor (locals)
- ngModelAccessor.andCallFake(function(val) {
- if (isDefined(val)) scope.value = val;
- return scope.value;
+ $scope: scope, $element: element.find('input'), $attrs: attrs
});
}));
@@ -32,6 +27,26 @@ describe('NgModelController', function() {
});
+ it('should fail on non-assignable model binding', inject(function($controller) {
+ var exception;
+
+ try {
+ $controller(NgModelController, {
+ $scope: null,
+ $element: jqLite('<input ng-model="1+2">'),
+ $attrs: {
+ ngModel: '1+2'
+ }
+ });
+ } catch (e) {
+ exception = e;
+ }
+
+ expect(exception.message).
+ toMatch(/Non-assignable model expression: 1\+2 \(<input( value="")? ng-model="1\+2">\)/);
+ }));
+
+
it('should init the properties', function() {
expect(ctrl.$dirty).toBe(false);
expect(ctrl.$pristine).toBe(true);