Skip to content

Commit

Permalink
Added test for style caching when in deferred measurement mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Feb 15, 2017
1 parent 30b2112 commit de4fcfe
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions source/Grid/Grid.jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { findDOMNode } from 'react-dom'
import { Simulate } from 'react-addons-test-utils'
import { render } from '../TestUtils'
import Grid, { DEFAULT_SCROLLING_RESET_TIME_INTERVAL } from './Grid'
import CellMeasurerCache from '../CellMeasurer/CellMeasurerCache'
import { SCROLL_DIRECTION_BACKWARD, SCROLL_DIRECTION_FORWARD } from './utils/getOverscanIndices'
import { DEFAULT_MAX_SCROLL_SIZE } from './utils/ScalingCellSizeAndPositionManager'

Expand Down Expand Up @@ -1551,6 +1552,22 @@ describe('Grid', () => {
expect(firstProps.style).not.toBe(secondProps.style)
})

it('should only cache styles when a :deferredMeasurementCache is provided if the cell has already been measured', () => {
const cache = new CellMeasurerCache()
cache.set(0, 0, 100, 100)
cache.set(1, 1, 100, 100)

const grid = render(getMarkup({
columnCount: 2,
deferredMeasurementCache: cache,
rowCount: 2
}))

const keys = Object.keys(grid._styleCache)

expect(keys).toEqual(['0-0', '1-1'])
})

it('should warn about cells that forget to include the :style property', () => {
spyOn(console, 'warn')

Expand Down

0 comments on commit de4fcfe

Please sign in to comment.