@@ -59,7 +59,7 @@ afterAll(() => {
59
59
Globals . assign ( { skipAnimation : false } )
60
60
} )
61
61
62
- it ( 'should render a basic heamap chart' , ( ) => {
62
+ it ( 'should render a basic heatmap chart' , ( ) => {
63
63
const wrapper = mount ( < HeatMap { ...baseProps } /> )
64
64
65
65
dataPoints . forEach ( datum => {
@@ -72,26 +72,59 @@ it('should render a basic heamap chart', () => {
72
72
} )
73
73
} )
74
74
75
+ describe ( 'force square cells' , ( ) => {
76
+ const expectedSquareSize = 100
77
+
78
+ CELL_SHAPES . forEach ( shape => {
79
+ describe ( shape , ( ) => {
80
+ it ( 'cells should have square dimensions' , ( ) => {
81
+ const wrapper = mount (
82
+ < HeatMap { ...baseProps } cellComponent = { shape } width = { 2000 } forceSquare />
83
+ )
84
+
85
+ dataPoints . forEach ( datum => {
86
+ const cell = wrapper . find ( `g[data-testid='cell.${ datum . id } ']` )
87
+ const cellShape = cell . find ( shape ) . parent ( )
88
+
89
+ if ( shape === 'rect' ) {
90
+ expect ( cellShape . prop < SpringValue < number > > ( 'width' ) . get ( ) ) . toEqual (
91
+ expectedSquareSize
92
+ )
93
+ expect ( cellShape . prop < SpringValue < number > > ( 'height' ) . get ( ) ) . toEqual (
94
+ expectedSquareSize
95
+ )
96
+ } else {
97
+ expect ( cellShape . prop < SpringValue < number > > ( 'r' ) . get ( ) * 2 ) . toEqual (
98
+ expectedSquareSize
99
+ )
100
+ }
101
+ } )
102
+ } )
103
+ } )
104
+ } )
105
+ } )
106
+
75
107
describe ( 'size variation' , ( ) => {
108
+ // use simpler data for easier assertions
109
+ const sizeVariationData = [
110
+ {
111
+ id : 'A' ,
112
+ data : [
113
+ { x : 'X' , y : 5 } ,
114
+ { x : 'Y' , y : 10 } ,
115
+ ] ,
116
+ } ,
117
+ {
118
+ id : 'B' ,
119
+ data : [
120
+ { x : 'X' , y : 7.5 } ,
121
+ { x : 'Y' , y : 10 } ,
122
+ ] ,
123
+ } ,
124
+ ]
125
+
76
126
CELL_SHAPES . forEach ( shape => {
77
127
describe ( shape , ( ) => {
78
- // use simpler data for easier assertions
79
- const sizeVariationData = [
80
- {
81
- id : 'A' ,
82
- data : [
83
- { x : 'X' , y : 5 } ,
84
- { x : 'Y' , y : 10 } ,
85
- ] ,
86
- } ,
87
- {
88
- id : 'B' ,
89
- data : [
90
- { x : 'X' , y : 7.5 } ,
91
- { x : 'Y' , y : 10 } ,
92
- ] ,
93
- } ,
94
- ]
95
128
const cellIdAndValues : { id : string ; value : number } [ ] = [ ]
96
129
sizeVariationData . forEach ( serie => {
97
130
serie . data . forEach ( datum => {
0 commit comments