1- describe ( 'uiScroll' , function ( ) {
1+ describe ( 'uiScroll' , ( ) => {
22 'use strict' ;
33
44 let datasource ;
55 beforeEach ( module ( 'ui.scroll' ) ) ;
66 beforeEach ( module ( 'ui.scroll.test.datasources' ) ) ;
77
8- const injectDatasource = ( datasourceToken ) =>
8+ const injectDatasource = datasourceToken =>
99 beforeEach (
10- inject ( [ datasourceToken , function ( _datasource ) {
11- datasource = _datasource ;
12- } ] )
10+ inject ( [ datasourceToken , _datasource =>
11+ datasource = _datasource
12+ ] )
1313 ) ;
1414
15- describe ( 'buffer cleanup' , function ( ) {
16- var getSettings = function ( ) {
17- return {
18- datasource : 'myEdgeDatasource' ,
19- adapter : 'adapter' ,
20- viewportHeight : 60 ,
21- itemHeight : 20 ,
22- padding : 0.3 ,
23- startIndex : 3 ,
24- bufferSize : 3
25- } ;
15+ describe ( 'buffer cleanup' , ( ) => {
16+ const settings = {
17+ datasource : 'myEdgeDatasource' , // items range is [-5..6]
18+ adapter : 'adapter' ,
19+ viewportHeight : 60 ,
20+ itemHeight : 20 ,
21+ padding : 0.3 ,
22+ startIndex : 3 ,
23+ bufferSize : 3
2624 } ;
2725
2826 injectDatasource ( 'myEdgeDatasource' ) ;
2927
30- var cleanBuffer = function ( scope , applyUpdateOptions ) {
31- var get = datasource . get ;
32- var removedItems = [ ] ;
28+ const cleanBuffer = ( scope , applyUpdateOptions ) => {
29+ const get = datasource . get ;
30+ const removedItems = [ ] ;
3331 // sync the datasource
34- datasource . get = function ( index , count , success ) {
35- var removedIndex = removedItems . indexOf ( 'item' + index ) ;
36- if ( removedIndex !== - 1 ) {
37- // todo consider mutable-top case
38- index += removedItems . length ; // - removedIndex;
32+ datasource . get = ( index , count , success ) => {
33+ if ( removedItems . indexOf ( 'item' + index ) !== - 1 ) {
34+ index += removedItems . length ;
3935 }
4036 get ( index , count , success ) ;
4137 } ;
4238 // clean up the buffer
43- scope . adapter . applyUpdates ( function ( item ) {
39+ scope . adapter . applyUpdates ( item => {
4440 removedItems . push ( item ) ;
4541 return [ ] ;
4642 } , applyUpdateOptions ) ;
4743 } ;
4844
49- var shouldWorkWhenEOF = function ( viewport , scope , options ) {
45+ const shouldWorkWhenEOF = ( viewport , scope , options ) => {
5046 expect ( scope . adapter . isBOF ( ) ) . toBe ( false ) ;
5147 expect ( scope . adapter . isEOF ( ) ) . toBe ( true ) ;
5248 expect ( scope . adapter . bufferFirst ) . toBe ( 'item0' ) ;
@@ -66,19 +62,19 @@ describe('uiScroll', function () {
6662 expect ( scope . adapter . bufferLength ) . toBe ( 5 ) ;
6763 } ;
6864
69- it ( 'should be consistent on forward direction when eof with immutabeTop' , function ( ) {
70- runTest ( getSettings ( ) , function ( viewport , scope ) {
71- shouldWorkWhenEOF ( viewport , scope , { immutableTop : true } ) ;
72- } ) ;
73- } ) ;
65+ it ( 'should be consistent on forward direction when eof with immutabeTop' , ( ) =>
66+ runTest ( settings , ( viewport , scope ) =>
67+ shouldWorkWhenEOF ( viewport , scope , { immutableTop : true } )
68+ )
69+ ) ;
7470
75- it ( 'should be consistent on forward direction when eof without immutabeTop' , function ( ) {
76- runTest ( getSettings ( ) , function ( viewport , scope ) {
77- shouldWorkWhenEOF ( viewport , scope ) ;
78- } ) ;
79- } ) ;
71+ it ( 'should be consistent on forward direction when eof without immutabeTop' , ( ) =>
72+ runTest ( settings , ( viewport , scope ) =>
73+ shouldWorkWhenEOF ( viewport , scope )
74+ )
75+ ) ;
8076
81- var shouldWorkWhenNotEOF = function ( viewport , scope , options ) {
77+ const shouldWorkWhenNotEOF = ( viewport , scope , options ) => {
8278 expect ( scope . adapter . isBOF ( ) ) . toBe ( false ) ;
8379 expect ( scope . adapter . isEOF ( ) ) . toBe ( false ) ;
8480 expect ( scope . adapter . bufferFirst ) . toBe ( 'item-4' ) ;
@@ -97,29 +93,32 @@ describe('uiScroll', function () {
9793 expect ( scope . adapter . bufferLength ) . toBe ( 4 ) ;
9894 } ;
9995
100- it ( 'should be consistent on forward direction when not eof with immutabeTop' , function ( ) {
101- var scrollSettings = getSettings ( ) ;
102- scrollSettings . startIndex = - 1 ;
103- scrollSettings . viewportHeight = 40 ;
104- runTest ( scrollSettings , function ( viewport , scope ) {
105- shouldWorkWhenNotEOF ( viewport , scope , { immutableTop : true } ) ;
106- } ) ;
107- } ) ;
108-
109- it ( 'should be consistent on forward direction when not eof without immutabeTop' , function ( ) {
110- var scrollSettings = getSettings ( ) ;
111- scrollSettings . startIndex = - 1 ;
112- scrollSettings . viewportHeight = 40 ;
113- runTest ( scrollSettings , function ( viewport , scope ) {
114- shouldWorkWhenNotEOF ( viewport , scope ) ;
115- } ) ;
116- } ) ;
117-
118- it ( 'should be consistent on backward direction when bof with immutableTop' , function ( ) {
119- var scrollSettings = getSettings ( ) ;
120- scrollSettings . startIndex = - 3 ;
121- scrollSettings . padding = 0.5 ;
122- runTest ( scrollSettings , function ( viewport , scope ) {
96+ it ( 'should be consistent on forward direction when not eof with immutabeTop' , ( ) =>
97+ runTest ( {
98+ ...settings ,
99+ startIndex : - 1 ,
100+ viewportHeight : 40
101+ } , ( viewport , scope ) =>
102+ shouldWorkWhenNotEOF ( viewport , scope , { immutableTop : true } )
103+ )
104+ ) ;
105+
106+ it ( 'should be consistent on forward direction when not eof without immutabeTop' , ( ) =>
107+ runTest ( {
108+ ...settings ,
109+ startIndex : - 1 ,
110+ viewportHeight : 40
111+ } , ( viewport , scope ) =>
112+ shouldWorkWhenNotEOF ( viewport , scope )
113+ )
114+ ) ;
115+
116+ it ( 'should be consistent on backward direction when bof with immutableTop' , ( ) =>
117+ runTest ( {
118+ ...settings ,
119+ startIndex : - 3 ,
120+ padding : 0.5
121+ } , ( viewport , scope ) => {
123122 expect ( scope . adapter . isBOF ( ) ) . toBe ( true ) ;
124123 expect ( scope . adapter . isEOF ( ) ) . toBe ( false ) ;
125124 expect ( scope . adapter . bufferFirst ) . toBe ( 'item-5' ) ;
@@ -137,14 +136,15 @@ describe('uiScroll', function () {
137136 expect ( Helper . getRow ( viewport , 4 ) ) . toBe ( '-2: item5' ) ;
138137 expect ( Helper . getRow ( viewport , 5 ) ) . toBe ( '-1: item6' ) ;
139138 expect ( scope . adapter . bufferLength ) . toBe ( 5 ) ;
140- } ) ;
141- } ) ;
142-
143- it ( 'should be consistent on backward direction when bof without immutableTop' , function ( ) {
144- var scrollSettings = getSettings ( ) ;
145- scrollSettings . startIndex = - 3 ;
146- scrollSettings . padding = 0.5 ;
147- runTest ( scrollSettings , function ( viewport , scope ) {
139+ } )
140+ ) ;
141+
142+ it ( 'should be consistent on backward direction when bof without immutableTop' , ( ) =>
143+ runTest ( {
144+ ...settings ,
145+ startIndex : - 3 ,
146+ padding : 0.5
147+ } , ( viewport , scope ) => {
148148 expect ( scope . adapter . isBOF ( ) ) . toBe ( true ) ;
149149 expect ( scope . adapter . isEOF ( ) ) . toBe ( false ) ;
150150 expect ( scope . adapter . bufferFirst ) . toBe ( 'item-5' ) ;
@@ -162,10 +162,10 @@ describe('uiScroll', function () {
162162 expect ( Helper . getRow ( viewport , 4 ) ) . toBe ( '5: item5' ) ;
163163 expect ( Helper . getRow ( viewport , 5 ) ) . toBe ( '6: item6' ) ;
164164 expect ( scope . adapter . bufferLength ) . toBe ( 5 ) ;
165- } ) ;
166- } ) ;
165+ } )
166+ ) ;
167167
168- var shouldWorkWhenNotBOF = function ( viewport , scope , options ) {
168+ const shouldWorkWhenNotBOF = ( viewport , scope , options ) => {
169169 expect ( scope . adapter . isBOF ( ) ) . toBe ( false ) ;
170170 expect ( scope . adapter . isEOF ( ) ) . toBe ( false ) ;
171171 expect ( scope . adapter . bufferFirst ) . toBe ( 'item-4' ) ;
@@ -185,24 +185,25 @@ describe('uiScroll', function () {
185185 expect ( scope . adapter . bufferLength ) . toBe ( 5 ) ;
186186 } ;
187187
188- it ( 'should be consistent on backward direction when not bof with immutableTop' , function ( ) {
189- var scrollSettings = getSettings ( ) ;
190- scrollSettings . startIndex = - 1 ;
191- scrollSettings . padding = 0.3 ;
192- runTest ( scrollSettings , function ( viewport , scope ) {
193- shouldWorkWhenNotBOF ( viewport , scope , { immutableTop : true } ) ;
194- } ) ;
195- } ) ;
196-
197- it ( 'should be consistent on backward direction when not bof without immutableTop' , function ( ) {
198- var scrollSettings = getSettings ( ) ;
199- scrollSettings . startIndex = - 1 ;
200- scrollSettings . padding = 0.3 ;
201- runTest ( scrollSettings , function ( viewport , scope ) {
202- shouldWorkWhenNotBOF ( viewport , scope ) ;
203- } ) ;
204- } ) ;
188+ it ( 'should be consistent on backward direction when not bof with immutableTop' , ( ) =>
189+ runTest ( {
190+ ...settings ,
191+ startIndex : - 1 ,
192+ padding : 0.3
193+ } , ( viewport , scope ) =>
194+ shouldWorkWhenNotBOF ( viewport , scope , { immutableTop : true } )
195+ )
196+ ) ;
205197
198+ it ( 'should be consistent on backward direction when not bof without immutableTop' , ( ) =>
199+ runTest ( {
200+ ...settings ,
201+ startIndex : - 1 ,
202+ padding : 0.3
203+ } , ( viewport , scope ) =>
204+ shouldWorkWhenNotBOF ( viewport , scope )
205+ )
206+ ) ;
206207 } ) ;
207208
208209} ) ;
0 commit comments