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

Commit c0cbe54

Browse files
committed
test($compile): extend $onChanges() test to account for one more case
Discussed in https://github.com/angular/angular.js/pull/15098/files#r77770755.
1 parent 7d7efbf commit c0cbe54

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

test/ng/compileSpec.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -4397,7 +4397,7 @@ describe('$compile', function() {
43974397
this.$onChanges = onChangesSpy;
43984398
}
43994399
});
4400-
});
4400+
});
44014401

44024402
inject(function($compile, $rootScope) {
44034403
var template = '<test prop="a" attr="{{a}}"></test>' +
@@ -4417,6 +4417,19 @@ describe('$compile', function() {
44174417
prop: jasmine.objectContaining({currentValue: NaN}),
44184418
attr: jasmine.objectContaining({currentValue: 'NaN'})
44194419
});
4420+
4421+
onChangesSpy.calls.reset();
4422+
$rootScope.$apply('a = "bar"; b = 42');
4423+
4424+
expect(onChangesSpy).toHaveBeenCalledTimes(2);
4425+
expect(onChangesSpy.calls.argsFor(0)[0]).toEqual({
4426+
prop: jasmine.objectContaining({previousValue: 'foo', currentValue: 'bar'}),
4427+
attr: jasmine.objectContaining({previousValue: 'foo', currentValue: 'bar'})
4428+
});
4429+
expect(onChangesSpy.calls.argsFor(1)[0]).toEqual({
4430+
prop: jasmine.objectContaining({previousValue: NaN, currentValue: 42}),
4431+
attr: jasmine.objectContaining({previousValue: 'NaN', currentValue: '42'})
4432+
});
44204433
});
44214434
});
44224435

0 commit comments

Comments
 (0)