@@ -27,45 +27,59 @@ describe('Ionic ScrollDelegate Service', function() {
27
27
expect ( sv ) . not . toBe ( undefined ) ;
28
28
} ) ;
29
29
30
- it ( 'Should scroll top' , function ( ) {
31
- spyOn ( del , 'register' ) ;
30
+ it ( 'should resize' , function ( ) {
31
+ var scope = rootScope . $new ( ) ;
32
+ var el = compile ( '<content></content>' ) ( scope ) ;
33
+
34
+ var sv = del . getScrollView ( scope ) ;
35
+ spyOn ( sv , 'resize' ) ;
32
36
37
+ del . resize ( ) ;
38
+ timeout . flush ( ) ;
39
+ expect ( sv . resize ) . toHaveBeenCalled ( ) ;
40
+ } ) ;
41
+
42
+ it ( 'Should resize & scroll top' , function ( ) {
33
43
var scope = rootScope . $new ( ) ;
34
44
var el = compile ( '<content start-y="100"></content>' ) ( scope ) ;
35
45
36
46
var sv = del . getScrollView ( scope ) ;
47
+ spyOn ( sv , 'resize' ) ;
37
48
38
- var v = sv . getValues ( ) ;
49
+ expect ( sv . getValues ( ) . top ) . toBe ( 100 ) ;
39
50
40
- expect ( v . top ) . toBe ( 100 ) ;
41
-
42
- del . scrollTop ( ) ;
51
+ del . scrollTop ( false ) ;
52
+ timeout . flush ( ) ;
53
+ expect ( sv . resize ) . toHaveBeenCalled ( ) ;
43
54
44
- expect ( v . top ) . toBe ( 100 ) ;
55
+ expect ( sv . getValues ( ) . top ) . toBe ( 0 ) ;
45
56
} ) ;
46
57
47
- /*
48
- it('Should scroll bottom', function() {
49
- spyOn(del, 'register');
50
-
58
+ it ( 'Should resize & scroll top' , function ( ) {
51
59
var scope = rootScope . $new ( ) ;
52
- var el = compile('<content start-y="100"><div style="height:1000px; width:100px;"></div>< /content>')(scope);
60
+ var el = compile ( '<content start-y="100"></content>' ) ( scope ) ;
53
61
54
62
var sv = del . getScrollView ( scope ) ;
55
- timeout.flush();
56
- sv.resize();
63
+ spyOn ( sv , 'resize' ) ;
57
64
58
- var v = sv.getValues();
65
+ expect ( sv . getValues ( ) . top ) . toBe ( 100 ) ;
59
66
67
+ del . scrollBottom ( false ) ;
68
+ timeout . flush ( ) ;
69
+ expect ( sv . resize ) . toHaveBeenCalled ( ) ;
60
70
61
- expect(v.top).toBe(100);
71
+ expect ( sv . getValues ( ) . top ) . toBe ( sv . getScrollMax ( ) . top ) ;
72
+ } ) ;
62
73
74
+ it ( 'should finish refreshing' , function ( ) {
75
+ var scope = rootScope . $new ( ) ;
76
+ var el = compile ( '<content start-y="100"></content>' ) ( scope ) ;
63
77
64
- console.log(sv.getScrollMax() );
65
- del.scrollBottom( );
78
+ var sv = del . getScrollView ( scope ) ;
79
+ spyOn ( sv , 'finishPullToRefresh' ) ;
66
80
67
- expect(v.top).toBe(100 );
68
- } );
69
- */
81
+ del . finishRefreshing ( scope ) ;
82
+ expect ( sv . finishPullToRefresh ) . toHaveBeenCalled ( ) ;
83
+ } ) ;
70
84
} ) ;
71
85
0 commit comments