diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 544baf8a74ca..4c4f1f589a2f 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -5453,7 +5453,7 @@ describe('$compile', function() { this.$onChanges = function(changes) { if (changes.input) { - log.push(['$onChanges', changes.input]); + log.push(['$onChanges', copy(changes.input)]); } }; } @@ -5482,6 +5482,53 @@ describe('$compile', function() { }); }); + it('should not update isolate again after $onInit if outer object reference has not changed', function() { + module('owComponentTest'); + inject(function() { + $rootScope.name = ['outer']; + compile(''); + + expect($rootScope.name).toEqual(['outer']); + expect(component.input).toEqual('$onInit'); + + $rootScope.name[0] = 'inner'; + $rootScope.$digest(); + + expect($rootScope.name).toEqual(['inner']); + expect(component.input).toEqual('$onInit'); + + expect(log).toEqual([ + 'constructor', + ['$onChanges', jasmine.objectContaining({ currentValue: ['outer'] })], + '$onInit' + ]); + }); + }); + + it('should update isolate again after $onInit if outer object reference changes even if equal', function() { + module('owComponentTest'); + inject(function() { + $rootScope.name = ['outer']; + compile(''); + + expect($rootScope.name).toEqual(['outer']); + expect(component.input).toEqual('$onInit'); + + $rootScope.name = ['outer']; + $rootScope.$digest(); + + expect($rootScope.name).toEqual(['outer']); + expect(component.input).toEqual(['outer']); + + expect(log).toEqual([ + 'constructor', + ['$onChanges', jasmine.objectContaining({ currentValue: ['outer'] })], + '$onInit', + ['$onChanges', jasmine.objectContaining({ previousValue: ['outer'], currentValue: ['outer'] })] + ]); + }); + }); + it('should not update isolate again after $onInit if outer is a literal', function() { module('owComponentTest'); inject(function() {