2
2
3
3
describe ( 'filterWatcherProvider' , function ( ) {
4
4
//helpers
5
- function n ( n ) { return n ; }
6
- var stub = { fn : function ( x ) { return n ( x ) } } ;
5
+ var stub = { fn : function ( x ) { return x ; } } ;
7
6
8
7
beforeEach ( module ( 'a8m.filter-watcher' ) ) ;
9
8
10
- it ( 'should have 2 main functions `isMemoized` and `memozie `' , inject ( function ( filterWatcher ) {
9
+ it ( 'should have 2 main functions `isMemoized` and `memoize `' , inject ( function ( filterWatcher ) {
11
10
expect ( filterWatcher . isMemoized ) . toEqual ( jasmine . any ( Function ) ) ;
12
11
expect ( filterWatcher . memoize ) . toEqual ( jasmine . any ( Function ) ) ;
13
12
} ) ) ;
14
13
15
- it ( 'should called the function if it\'s not cached' ,
14
+ it ( 'should call the function if it\'s not cached' ,
16
15
inject ( function ( filterWatcher ) {
17
16
var spy = spyOn ( stub , 'fn' ) ;
18
17
( function memoizedOnly ( n ) {
@@ -37,12 +36,10 @@ describe('filterWatcherProvider', function() {
37
36
} ) ( o1 ) ;
38
37
} ) ) ;
39
38
40
- it ( 'should get the result from cache if it\'s memoize ' ,
39
+ it ( 'should get the result from cache if it\'s memoized ' ,
41
40
inject ( function ( filterWatcher , $rootScope ) {
42
41
var scope = $rootScope . $new ( ) ;
43
- var spy = spyOn ( stub , 'fn' ) . andCallFake ( function ( ) {
44
- return 1 ;
45
- } ) ;
42
+ var spy = spyOn ( stub , 'fn' ) . andCallThrough ( ) ;
46
43
function memoize ( n ) {
47
44
return filterWatcher . isMemoized ( 'fName' , n ) ||
48
45
filterWatcher . memoize ( 'fName' , n , scope , stub . fn ( n ) ) ;
@@ -57,9 +54,7 @@ describe('filterWatcherProvider', function() {
57
54
it ( 'should clear cache from scope listeners on `$destroy`' ,
58
55
inject ( function ( filterWatcher , $rootScope ) {
59
56
var scope ;
60
- var spy = spyOn ( stub , 'fn' ) . andCallFake ( function ( ) {
61
- return 1 ;
62
- } ) ;
57
+ var spy = spyOn ( stub , 'fn' ) . andCallThrough ( ) ;
63
58
function memoize ( n ) {
64
59
return filterWatcher . isMemoized ( 'fName' , n ) ||
65
60
filterWatcher . memoize ( 'fName' , n , scope = $rootScope . $new ( ) , stub . fn ( n ) ) ;
0 commit comments