Skip to content

Commit 2da2e05

Browse files
Using a spy to make sure that the expectations are met.
1 parent 77d2e69 commit 2da2e05

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

test/ng/rootScopeSpec.js

+7
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,13 @@ describe('Scope', function() {
545545
var apples = {'item': 'apples'};
546546
var blackberries = {'item': 'blackberries'};
547547

548+
// use a spy to make sure the expectations are checked
549+
var spy = jasmine.createSpy();
550+
548551
$rootScope.$watchCollection('obj', function(newCollection, oldCollection) {
549552
if (oldCollection && !angular.equals(oldCollection, newCollection)) {
553+
spy();
554+
550555
expect(oldCollection.length).toEqual(1);
551556
expect(newCollection.length).toEqual(2);
552557

@@ -561,6 +566,8 @@ describe('Scope', function() {
561566

562567
$rootScope.obj.push(blackberries);
563568
$rootScope.$digest();
569+
570+
expect(spy).toHaveBeenCalledOnce();
564571
}))
565572
})
566573
});

0 commit comments

Comments
 (0)