22
33describe ( 'filterWatcherProvider' , function ( ) {
44 //helpers
5- function n ( n ) { return n ; }
6- var stub = { fn : function ( x ) { return n ( x ) } } ;
5+ var stub = { fn : function ( x ) { return x ; } } ;
76
87 beforeEach ( module ( 'a8m.filter-watcher' ) ) ;
98
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 ) {
1110 expect ( filterWatcher . isMemoized ) . toEqual ( jasmine . any ( Function ) ) ;
1211 expect ( filterWatcher . memoize ) . toEqual ( jasmine . any ( Function ) ) ;
1312 } ) ) ;
1413
15- it ( 'should called the function if it\'s not cached' ,
14+ it ( 'should call the function if it\'s not cached' ,
1615 inject ( function ( filterWatcher ) {
1716 var spy = spyOn ( stub , 'fn' ) ;
1817 ( function memoizedOnly ( n ) {
@@ -37,12 +36,10 @@ describe('filterWatcherProvider', function() {
3736 } ) ( o1 ) ;
3837 } ) ) ;
3938
40- it ( 'should get the result from cache if it\'s memoize ' ,
39+ it ( 'should get the result from cache if it\'s memoized ' ,
4140 inject ( function ( filterWatcher , $rootScope ) {
4241 var scope = $rootScope . $new ( ) ;
43- var spy = spyOn ( stub , 'fn' ) . andCallFake ( function ( ) {
44- return 1 ;
45- } ) ;
42+ var spy = spyOn ( stub , 'fn' ) . andCallThrough ( ) ;
4643 function memoize ( n ) {
4744 return filterWatcher . isMemoized ( 'fName' , n ) ||
4845 filterWatcher . memoize ( 'fName' , n , scope , stub . fn ( n ) ) ;
@@ -57,9 +54,7 @@ describe('filterWatcherProvider', function() {
5754 it ( 'should clear cache from scope listeners on `$destroy`' ,
5855 inject ( function ( filterWatcher , $rootScope ) {
5956 var scope ;
60- var spy = spyOn ( stub , 'fn' ) . andCallFake ( function ( ) {
61- return 1 ;
62- } ) ;
57+ var spy = spyOn ( stub , 'fn' ) . andCallThrough ( ) ;
6358 function memoize ( n ) {
6459 return filterWatcher . isMemoized ( 'fName' , n ) ||
6560 filterWatcher . memoize ( 'fName' , n , scope = $rootScope . $new ( ) , stub . fn ( n ) ) ;
0 commit comments