Skip to content

Commit 6a3c74b

Browse files
committed
test(localStorageSpec): test .bind with deep comparison
1 parent a425b43 commit 6a3c74b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/spec/localStorageSpec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,23 @@ describe('localStorageService', function() {
320320
expect($rootScope.property).toEqual(localStorageService.get('lsProperty'));
321321
}));
322322

323+
it('should $watch with deep comparison only for objects', inject(function($rootScope, localStorageService) {
324+
var mocks = [{}, [], 'string', 90, false];
325+
var expectation = [true, true, false, false, false];
326+
var results = [];
327+
328+
spyOn($rootScope, '$watch').andCallFake(function(key, func, eq) {
329+
results.push(eq);
330+
});
331+
332+
mocks.forEach(function(elm, i) {
333+
localStorageService.set('mock' + i, elm);
334+
localStorageService.bind($rootScope, 'mock' + i);
335+
});
336+
337+
expect(results).toEqual(expectation);
338+
}));
339+
323340
it('should be able to return it\'s owned keys amount', inject(
324341
function(localStorageService, $window) {
325342

0 commit comments

Comments
 (0)