test($compile): ensure equal but different instance changes are detected in onChanges
Closes #15300
This commit is contained in:
committed by
Georgios Kalpakas
parent
828f8a63b5
commit
41034bb41b
+48
-1
@@ -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('<ow-component input="name"></ow-component>');
|
||||
|
||||
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('<ow-component input="name"></ow-component>');
|
||||
|
||||
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() {
|
||||
|
||||
Reference in New Issue
Block a user