@@ -42,6 +42,36 @@ describe('uiScroll', function () {
42
42
} ) ;
43
43
} ) ;
44
44
45
+ describe ( 'datasource with 3 elements and buffersize 3 (new get signature)' , function ( ) {
46
+ var scrollSettings = { datasource : 'myNewOnePageDatasource' , bufferSize : 3 } ;
47
+
48
+ it ( 'should call get on the datasource 3 times ' , function ( ) {
49
+ var spy ;
50
+ inject ( function ( myNewOnePageDatasource ) {
51
+ spy = spyOn ( myNewOnePageDatasource , 'actualGet' ) . and . callThrough ( ) ;
52
+ runTest ( scrollSettings ,
53
+ function ( ) {
54
+ expect ( spy . calls . all ( ) . length ) . toBe ( 3 ) ;
55
+ expect ( spy . calls . all ( ) [ 0 ] . args [ 0 ] . index ) . toBe ( 1 ) ; // gets 3 rows (no eof)
56
+ expect ( spy . calls . all ( ) [ 0 ] . args [ 0 ] . count ) . toBe ( 3 ) ;
57
+ expect ( 'append' in spy . calls . all ( ) [ 0 ] . args [ 0 ] ) . toBe ( true ) ;
58
+ expect ( spy . calls . all ( ) [ 0 ] . args [ 0 ] . append ) . toBeUndefined ( ) ;
59
+ expect ( 'prepend' in spy . calls . all ( ) [ 0 ] . args [ 0 ] ) . toBe ( false ) ;
60
+ expect ( spy . calls . all ( ) [ 1 ] . args [ 0 ] . index ) . toBe ( 4 ) ; // gets 0 rows (and eof)
61
+ expect ( spy . calls . all ( ) [ 1 ] . args [ 0 ] . count ) . toBe ( 3 ) ;
62
+ expect ( 'append' in spy . calls . all ( ) [ 1 ] . args [ 0 ] ) . toBe ( true ) ;
63
+ expect ( spy . calls . all ( ) [ 1 ] . args [ 0 ] . append ) . toBe ( 'three' ) ;
64
+ expect ( 'prepend' in spy . calls . all ( ) [ 1 ] . args [ 0 ] ) . toBe ( false ) ;
65
+ expect ( spy . calls . all ( ) [ 2 ] . args [ 0 ] . index ) . toBe ( - 2 ) ; // gets 0 rows (and bof)
66
+ expect ( spy . calls . all ( ) [ 2 ] . args [ 0 ] . count ) . toBe ( 3 ) ;
67
+ expect ( 'append' in spy . calls . all ( ) [ 2 ] . args [ 0 ] ) . toBe ( false ) ;
68
+ expect ( 'prepend' in spy . calls . all ( ) [ 2 ] . args [ 0 ] ) . toBe ( true ) ;
69
+ expect ( spy . calls . all ( ) [ 2 ] . args [ 0 ] . prepend ) . toBe ( 'one' ) ;
70
+ } ) ;
71
+ } ) ;
72
+ } ) ;
73
+ } ) ;
74
+
45
75
describe ( 'datasource with only 3 elements (negative index)' , function ( ) {
46
76
var scrollSettings = { datasource : 'anotherDatasource' } ;
47
77
it ( 'should create 3 divs with data (+ 2 padding divs)' , function ( ) {
0 commit comments