Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
test($compile): add test for undefined non-optional reference binding
Browse files Browse the repository at this point in the history
Demonstrates that #13373 fixes #13367
  • Loading branch information
petebacondarwin committed Nov 25, 2015
1 parent 7bb2414 commit 45c5688
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/ng/compileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3953,7 +3953,7 @@ describe('$compile', function() {
expect(componentScope.ref).toBe('hello world');

componentScope.ref = 'ignore me';
expect($rootScope.$apply).
expect(function() { $rootScope.$apply(); }).
toThrowMinErr("$compile", "nonassign", "Expression ''hello ' + name' used with directive 'myComponent' is non-assignable!");
expect(componentScope.ref).toBe('hello world');
// reset since the exception was rethrown which prevented phase clearing
Expand All @@ -3964,6 +3964,21 @@ describe('$compile', function() {
expect(componentScope.ref).toBe('hello misko');
}));

it('should complain if assigning to undefined', inject(function() {
compile('<div><span my-component>');
$rootScope.$apply();
expect(componentScope.ref).toBeUndefined();

componentScope.ref = 'ignore me';
expect(function() { $rootScope.$apply(); }).
toThrowMinErr("$compile", "nonassign", "Expression 'undefined' used with directive 'myComponent' is non-assignable!");
expect(componentScope.ref).toBeUndefined();

$rootScope.$$phase = null; // reset since the exception was rethrown which prevented phase clearing
$rootScope.$apply();
expect(componentScope.ref).toBeUndefined();
}));

// regression
it('should stabilize model', inject(function() {
compile('<div><span my-component reference="name">');
Expand Down

0 comments on commit 45c5688

Please sign in to comment.