Created
March 4, 2018 20:24
-
-
Save petersendidit/a80d38510a2d752a231715061ab3eab1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/source/MultiGrid/MultiGrid.jest.js b/source/MultiGrid/MultiGrid.jest.js | |
index 501c6cd..e751c79 100644 | |
--- a/source/MultiGrid/MultiGrid.jest.js | |
+++ b/source/MultiGrid/MultiGrid.jest.js | |
@@ -248,13 +248,13 @@ describe('MultiGrid', () => { | |
expect(bottomLeftAfter.style.getPropertyValue('width')).toEqual('75px'); | |
expect(bottomRightAfter.style.getPropertyValue('width')).toEqual('325px'); | |
}); | |
- | |
+ | |
it('should update the MultiGrid width when cell width changes by getter function', () => { | |
let columnWidths = [100, 100, 100, 100, 100]; | |
function getCoumnWidth({index}) { | |
return columnWidths[index]; | |
} | |
- | |
+ | |
let multiGrid; | |
let rendered = findDOMNode( | |
render( | |
@@ -277,7 +277,7 @@ describe('MultiGrid', () => { | |
expect(topRight.style.getPropertyValue('width')).toEqual('300px'); | |
expect(bottomLeft.style.getPropertyValue('width')).toEqual('100px'); | |
expect(bottomRight.style.getPropertyValue('width')).toEqual('300px'); | |
- | |
+ | |
columnWidths = [80, 100, 100, 100, 100]; | |
multiGrid.recomputeGridSize(); | |
@@ -286,6 +286,44 @@ describe('MultiGrid', () => { | |
expect(bottomLeft.style.getPropertyValue('width')).toEqual('80px'); | |
expect(bottomRight.style.getPropertyValue('width')).toEqual('320px'); | |
}); | |
+ | |
+ it('should update the MultiGrid width when cell height changes by getter function', () => { | |
+ let rowHeights = [30, 30, 30, 30, 30]; | |
+ function getRowHeight({index}) { | |
+ return rowHeights[index] || 30; | |
+ } | |
+ | |
+ let multiGrid; | |
+ let rendered = findDOMNode( | |
+ render( | |
+ getMarkup({ | |
+ fixedColumnCount: 1, | |
+ fixedRowCount: 1, | |
+ rowHeight: getRowHeight, | |
+ columnWidth: 100, | |
+ ref: ref => { | |
+ multiGrid = ref; | |
+ }, | |
+ }), | |
+ ), | |
+ ); | |
+ | |
+ let grids = rendered.querySelectorAll('.ReactVirtualized__Grid'); | |
+ expect(grids.length).toEqual(4); | |
+ let [topLeft, topRight, bottomLeft, bottomRight] = grids; | |
+ expect(topLeft.style.getPropertyValue('height')).toEqual('30px'); | |
+ expect(topRight.style.getPropertyValue('height')).toEqual('30px'); | |
+ expect(bottomLeft.style.getPropertyValue('height')).toEqual('270px'); | |
+ expect(bottomRight.style.getPropertyValue('height')).toEqual('270px'); | |
+ | |
+ rowHeights = [50, 30, 30, 30, 30]; | |
+ multiGrid.recomputeGridSize(); | |
+ | |
+ expect(topLeft.style.getPropertyValue('height')).toEqual('50px'); | |
+ expect(topRight.style.getPropertyValue('height')).toEqual('50px'); | |
+ expect(bottomLeft.style.getPropertyValue('height')).toEqual('250px'); | |
+ expect(bottomRight.style.getPropertyValue('height')).toEqual('250px'); | |
+ }); | |
}); | |
describe('scrollToColumn and scrollToRow', () => { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment