@@ -138,8 +138,36 @@ describe('Grid', () => {
138138 expect ( grid . state . scrollTop ) . toEqual ( 1900 )
139139 } )
140140
141- // @TODO Test updating with new row + scrollTop, removing row, scrolling, then re-adding row (with same scrollTop)
142- // @TODO Test updating with new row + scrollToIndex, removing row, scrolling, then re-adding row (with same scrollToIndex)
141+ it ( 'should scroll to a row and column just added' , ( ) => {
142+ let grid = render ( getMarkup ( ) )
143+ expect ( grid . state . scrollLeft ) . toEqual ( 0 )
144+ expect ( grid . state . scrollTop ) . toEqual ( 0 )
145+ grid = render ( getMarkup ( {
146+ columnsCount : NUM_COLUMNS + 1 ,
147+ rowsCount : NUM_ROWS + 1 ,
148+ scrollToColumn : NUM_COLUMNS ,
149+ scrollToRow : NUM_ROWS
150+ } ) )
151+ expect ( grid . state . scrollLeft ) . toEqual ( 2350 )
152+ expect ( grid . state . scrollTop ) . toEqual ( 1920 )
153+ } )
154+
155+ it ( 'should scroll back to a newly-added cell without a change in prop' , ( ) => {
156+ let grid = render ( getMarkup ( {
157+ columnsCount : NUM_COLUMNS ,
158+ rowsCount : NUM_ROWS ,
159+ scrollToColumn : NUM_COLUMNS ,
160+ scrollToRow : NUM_ROWS
161+ } ) )
162+ grid = render ( getMarkup ( {
163+ columnsCount : NUM_COLUMNS + 1 ,
164+ rowsCount : NUM_ROWS + 1 ,
165+ scrollToColumn : NUM_COLUMNS ,
166+ scrollToRow : NUM_ROWS
167+ } ) )
168+ expect ( grid . state . scrollLeft ) . toEqual ( 2350 )
169+ expect ( grid . state . scrollTop ) . toEqual ( 1920 )
170+ } )
143171 } )
144172
145173 describe ( 'property updates' , ( ) => {
0 commit comments