Skip to content

Commit 5546834

Browse files
committed
revert HEAD
1 parent abce054 commit 5546834

File tree

2 files changed

+83
-83
lines changed

2 files changed

+83
-83
lines changed

test/spec/filter/collection/group-by.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,29 +66,29 @@ describe('groupByFilter', function() {
6666
expect(filter(null)).toBeNull();
6767
});
6868

69-
// describe('inside the DOM', function() {
70-
// it('should not throw and not trigger the infinite digest exception',
71-
// inject(function($rootScope, $compile) {
72-
// var scope = $rootScope.$new();
73-
// scope.players = [
74-
// { name: 'foo', team: 'a' },
75-
// { name: 'lol', team: 'b' },
76-
// { name: 'bar', team: 'b' },
77-
// { name: 'baz', team: 'a' }
78-
// ];
79-
// scope.search = '';
80-
// var elm = angular.element(
81-
// '<ul>' +
82-
// '<li ng-repeat="(key, val) in players | filter: search | groupBy: \'team\'">' +
83-
// '{{ key }}' +
84-
// '<p ng-repeat="v in val"> {{ v }}</p>' +
85-
// '</li>' +
86-
// '</ul>'
87-
// );
88-
// var temp = $compile(elm)(scope);
89-
// expect(function() { scope.$digest() }).not.toThrow();
90-
// expect(temp.children().length).toEqual(2);
91-
// }));
92-
// });
69+
describe('inside the DOM', function() {
70+
it('should not throw and not trigger the infinite digest exception',
71+
inject(function($rootScope, $compile) {
72+
var scope = $rootScope.$new();
73+
scope.players = [
74+
{ name: 'foo', team: 'a' },
75+
{ name: 'lol', team: 'b' },
76+
{ name: 'bar', team: 'b' },
77+
{ name: 'baz', team: 'a' }
78+
];
79+
scope.search = '';
80+
var elm = angular.element(
81+
'<ul>' +
82+
'<li ng-repeat="(key, val) in players | filter: search | groupBy: \'team\'">' +
83+
'{{ key }}' +
84+
'<p ng-repeat="v in val"> {{ v }}</p>' +
85+
'</li>' +
86+
'</ul>'
87+
);
88+
var temp = $compile(elm)(scope);
89+
expect(function() { scope.$digest() }).not.toThrow();
90+
expect(temp.children().length).toEqual(2);
91+
}));
92+
});
9393

9494
});

test/spec/provider/watcher.js

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
1-
//'use strict';
2-
//
3-
//describe('filterWatcherProvider', function() {
4-
//
5-
// //helpers
6-
// function n(n) { return n; }
7-
// var stub = { fn: function(x) { return n(x) } };
8-
//
9-
// beforeEach(module('a8m.filter-watcher'));
10-
//
11-
// it('should have 2 main functions `isMemoized` and `memozie`', inject(function(filterWatcher) {
12-
// expect(filterWatcher.isMemoized).toEqual(jasmine.any(Function));
13-
// expect(filterWatcher.memoize).toEqual(jasmine.any(Function));
14-
// }));
15-
//
16-
// it('should called the function if it\'s not cached',
17-
// inject(function(filterWatcher) {
18-
// var spy = spyOn(stub, 'fn');
19-
// (function memoizedOnly(n) {
20-
// return filterWatcher.isMemoized('fName',n) || stub.fn(n);
21-
// })();
22-
// expect(spy).toHaveBeenCalled();
23-
// expect(spy.callCount).toEqual(1);
24-
// }));
25-
//
26-
// it('should get the result from cache if it\'s memoize',
27-
// inject(function(filterWatcher, $rootScope) {
28-
// var scope = $rootScope.$new();
29-
// var spy = spyOn(stub, 'fn').andCallFake(function() {
30-
// return 1;
31-
// });
32-
// function memoize(n) {
33-
// return filterWatcher.isMemoized('fName', n) ||
34-
// filterWatcher.memoize('fName', n, scope, stub.fn(n));
35-
// }
36-
// [1,1,1,1,4,4,4,4,4].forEach(function(el) {
37-
// memoize(el);
38-
// });
39-
// expect(spy).toHaveBeenCalled();
40-
// expect(spy.callCount).toEqual(2);
41-
// }));
42-
//
43-
// it('should clear cache from scope listeners on `$destroy`',
44-
// inject(function(filterWatcher, $rootScope) {
45-
// var scope;
46-
// var spy = spyOn(stub, 'fn').andCallFake(function() {
47-
// return 1;
48-
// });
49-
// function memoize(n) {
50-
// return filterWatcher.isMemoized('fName', n) ||
51-
// filterWatcher.memoize('fName', n, scope = $rootScope.$new(), stub.fn(n));
52-
// }
53-
// [1,1,1,1,1,1,1,1,1,1].forEach(function(el) {
54-
// memoize(el);
55-
// scope.$destroy();
56-
// });
57-
// expect(spy.callCount).toEqual(10);
58-
// }));
59-
//});
1+
'use strict';
2+
3+
describe('filterWatcherProvider', function() {
4+
5+
//helpers
6+
function n(n) { return n; }
7+
var stub = { fn: function(x) { return n(x) } };
8+
9+
beforeEach(module('a8m.filter-watcher'));
10+
11+
it('should have 2 main functions `isMemoized` and `memozie`', inject(function(filterWatcher) {
12+
expect(filterWatcher.isMemoized).toEqual(jasmine.any(Function));
13+
expect(filterWatcher.memoize).toEqual(jasmine.any(Function));
14+
}));
15+
16+
it('should called the function if it\'s not cached',
17+
inject(function(filterWatcher) {
18+
var spy = spyOn(stub, 'fn');
19+
(function memoizedOnly(n) {
20+
return filterWatcher.isMemoized('fName',n) || stub.fn(n);
21+
})();
22+
expect(spy).toHaveBeenCalled();
23+
expect(spy.callCount).toEqual(1);
24+
}));
25+
26+
it('should get the result from cache if it\'s memoize',
27+
inject(function(filterWatcher, $rootScope) {
28+
var scope = $rootScope.$new();
29+
var spy = spyOn(stub, 'fn').andCallFake(function() {
30+
return 1;
31+
});
32+
function memoize(n) {
33+
return filterWatcher.isMemoized('fName', n) ||
34+
filterWatcher.memoize('fName', n, scope, stub.fn(n));
35+
}
36+
[1,1,1,1,4,4,4,4,4].forEach(function(el) {
37+
memoize(el);
38+
});
39+
expect(spy).toHaveBeenCalled();
40+
expect(spy.callCount).toEqual(2);
41+
}));
42+
43+
it('should clear cache from scope listeners on `$destroy`',
44+
inject(function(filterWatcher, $rootScope) {
45+
var scope;
46+
var spy = spyOn(stub, 'fn').andCallFake(function() {
47+
return 1;
48+
});
49+
function memoize(n) {
50+
return filterWatcher.isMemoized('fName', n) ||
51+
filterWatcher.memoize('fName', n, scope = $rootScope.$new(), stub.fn(n));
52+
}
53+
[1,1,1,1,1,1,1,1,1,1].forEach(function(el) {
54+
memoize(el);
55+
scope.$destroy();
56+
});
57+
expect(spy.callCount).toEqual(10);
58+
}));
59+
});

0 commit comments

Comments
 (0)