Skip to content

Commit bba8262

Browse files
gkalpakpetebacondarwin
authored andcommitted
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 1045a4b commit bba8262

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
@@ -4357,7 +4357,7 @@ describe('$compile', function() {
43574357
this.$onChanges = onChangesSpy;
43584358
}
43594359
});
4360-
});
4360+
});
43614361

43624362
inject(function($compile, $rootScope) {
43634363
var template = '<test prop="a" attr="{{a}}"></test>' +
@@ -4377,6 +4377,19 @@ describe('$compile', function() {
43774377
prop: jasmine.objectContaining({currentValue: NaN}),
43784378
attr: jasmine.objectContaining({currentValue: 'NaN'})
43794379
});
4380+
4381+
onChangesSpy.calls.reset();
4382+
$rootScope.$apply('a = "bar"; b = 42');
4383+
4384+
expect(onChangesSpy).toHaveBeenCalledTimes(2);
4385+
expect(onChangesSpy.calls.argsFor(0)[0]).toEqual({
4386+
prop: jasmine.objectContaining({previousValue: 'foo', currentValue: 'bar'}),
4387+
attr: jasmine.objectContaining({previousValue: 'foo', currentValue: 'bar'})
4388+
});
4389+
expect(onChangesSpy.calls.argsFor(1)[0]).toEqual({
4390+
prop: jasmine.objectContaining({previousValue: NaN, currentValue: 42}),
4391+
attr: jasmine.objectContaining({previousValue: 'NaN', currentValue: '42'})
4392+
});
43804393
});
43814394
});
43824395

0 commit comments

Comments
 (0)