@@ -55,9 +55,10 @@ describe('dashboard layout', () => {
5555 expect ( dashboard . offsetHeight ) . to . eql ( 0 ) ;
5656 } ) ;
5757
58- it ( 'should be responsive' , ( ) => {
58+ it ( 'should be responsive' , async ( ) => {
5959 // Narrow down the component to fit one column
6060 dashboard . style . width = `${ columnWidth } px` ;
61+ await nextFrame ( ) ;
6162
6263 /* prettier-ignore */
6364 expectLayout ( dashboard , [
@@ -97,35 +98,39 @@ describe('dashboard layout', () => {
9798 } ) ;
9899
99100 describe ( 'minimum column width' , ( ) => {
100- it ( 'should have a default minimum column width' , ( ) => {
101+ it ( 'should have a default minimum column width' , async ( ) => {
101102 // Clear the minimum column width used in the tests
102103 setMinimumColumnWidth ( dashboard , undefined ) ;
103104 // Narrow down the component to have the width of 0
104105 dashboard . style . width = '0' ;
106+ await nextFrame ( ) ;
105107 // Expect the column width to equal the default minimum column width
106108 expect ( getColumnWidths ( dashboard ) ) . to . eql ( [ remValue * 25 ] ) ;
107109 } ) ;
108110
109- it ( 'should have one overflown column if narrowed below minimum column width' , ( ) => {
111+ it ( 'should have one overflown column if narrowed below minimum column width' , async ( ) => {
110112 // Narrow down the component to have the width of half a column
111113 dashboard . style . width = `${ columnWidth / 2 } px` ;
114+ await nextFrame ( ) ;
112115 // Expect the column width to still be the same (overflown)
113116 expect ( getColumnWidths ( dashboard ) ) . to . eql ( [ columnWidth ] ) ;
114117 } ) ;
115118
116- it ( 'should not overflow if narrowed to the minimum column width' , ( ) => {
119+ it ( 'should not overflow if narrowed to the minimum column width' , async ( ) => {
117120 // Set the min column width to half of the column width
118121 setMinimumColumnWidth ( dashboard , columnWidth / 2 ) ;
119122 // Narrow down the component to have the width of half a column
120123 dashboard . style . width = `${ columnWidth / 2 } px` ;
124+ await nextFrame ( ) ;
121125 // Expect the column width to equal the min column width
122126 expect ( getColumnWidths ( dashboard ) ) . to . eql ( [ columnWidth / 2 ] ) ;
123127 } ) ;
124128
125- it ( 'should have one wide column with large minimum column width' , ( ) => {
129+ it ( 'should have one wide column with large minimum column width' , async ( ) => {
126130 setMaximumColumnWidth ( dashboard , columnWidth * 2 ) ;
127131 // Set the min column width to be twice as wide
128132 setMinimumColumnWidth ( dashboard , columnWidth * 2 ) ;
133+ await nextFrame ( ) ;
129134 // Expect there to only be one column with twice the width
130135 expect ( getColumnWidths ( dashboard ) ) . to . eql ( [ columnWidth * 2 ] ) ;
131136 /* prettier-ignore */
@@ -137,24 +142,28 @@ describe('dashboard layout', () => {
137142 } ) ;
138143
139144 describe ( 'maximum column width' , ( ) => {
140- it ( 'should have a default maximum column width' , ( ) => {
145+ it ( 'should have a default maximum column width' , async ( ) => {
141146 // Clear the maximum column width used in the tests
142147 setMaximumColumnWidth ( dashboard , undefined ) ;
143148 expect ( getColumnWidths ( dashboard ) ) . to . eql ( [ columnWidth , columnWidth ] ) ;
144149 // Widen the component to have the width of 2.5 columns
145150 dashboard . style . width = `${ columnWidth * 2.5 } px` ;
151+ await nextFrame ( ) ;
146152 expect ( getColumnWidths ( dashboard ) ) . to . eql ( [ columnWidth * 1.25 , columnWidth * 1.25 ] ) ;
147153 // Widen the component to have the width of 3 columns
148154 dashboard . style . width = `${ columnWidth * 3 } px` ;
155+ await nextFrame ( ) ;
149156 expect ( getColumnWidths ( dashboard ) ) . to . eql ( [ columnWidth , columnWidth , columnWidth ] ) ;
150157 // Shrink the component to have the width of 1.5 columns
151158 dashboard . style . width = `${ columnWidth * 1.5 } px` ;
159+ await nextFrame ( ) ;
152160 expect ( getColumnWidths ( dashboard ) ) . to . eql ( [ columnWidth * 1.5 ] ) ;
153161 } ) ;
154162
155- it ( 'should have one wide column with large maximum column width' , ( ) => {
163+ it ( 'should have one wide column with large maximum column width' , async ( ) => {
156164 // Allow the column to be twice as wide
157165 setMaximumColumnWidth ( dashboard , columnWidth * 2 ) ;
166+ await nextFrame ( ) ;
158167 // Expect there to only be one column with twice the width
159168 expect ( getColumnWidths ( dashboard ) ) . to . eql ( [ columnWidth * 2 ] ) ;
160169 /* prettier-ignore */
@@ -168,26 +177,30 @@ describe('dashboard layout', () => {
168177 describe ( 'minimum row height' , ( ) => {
169178 const rowHeight = 100 ;
170179
171- it ( 'should have the row height of the highest wigdet on a row by default' , ( ) => {
180+ it ( 'should have the row height of the highest wigdet on a row by default' , async ( ) => {
172181 childElements [ 0 ] . style . height = `${ rowHeight } px` ;
173182 childElements [ 1 ] . style . height = '50px' ;
183+ await nextFrame ( ) ;
174184 expect ( getRowHeights ( dashboard ) ) . to . eql ( [ rowHeight ] ) ;
175185 } ) ;
176186
177- it ( 'should set a minimum row height' , ( ) => {
187+ it ( 'should set a minimum row height' , async ( ) => {
178188 setMinimumRowHeight ( dashboard , rowHeight ) ;
189+ await nextFrame ( ) ;
179190 expect ( getRowHeights ( dashboard ) ) . to . eql ( [ rowHeight ] ) ;
180191 } ) ;
181192
182- it ( 'should not constrain widgets to the minumum row height' , ( ) => {
193+ it ( 'should not constrain widgets to the minumum row height' , async ( ) => {
183194 childElements [ 0 ] . style . height = `${ rowHeight * 2 } px` ;
184195 setMinimumRowHeight ( dashboard , rowHeight ) ;
196+ await nextFrame ( ) ;
185197 expect ( getRowHeights ( dashboard ) ) . to . eql ( [ rowHeight * 2 ] ) ;
186198 } ) ;
187199
188- it ( 'should use minimum row height for all rows' , ( ) => {
200+ it ( 'should use minimum row height for all rows' , async ( ) => {
189201 dashboard . style . width = `${ columnWidth } px` ;
190202 setMinimumRowHeight ( dashboard , rowHeight ) ;
203+ await nextFrame ( ) ;
191204 expect ( getRowHeights ( dashboard ) ) . to . eql ( [ rowHeight , rowHeight ] ) ;
192205 } ) ;
193206 } ) ;
@@ -293,34 +306,37 @@ describe('dashboard layout', () => {
293306 } ) ;
294307
295308 describe ( 'gap' , ( ) => {
296- it ( 'should have a default gap' , ( ) => {
309+ it ( 'should have a default gap' , async ( ) => {
297310 // Clear the gap used in the tests
298311 setGap ( dashboard , undefined ) ;
299312 // Increase the width of the dashboard to fit two items and a gap
300313 dashboard . style . width = `${ columnWidth * 2 + remValue } px` ;
314+ await nextFrame ( ) ;
301315
302316 const { right : item0Right } = childElements [ 0 ] . getBoundingClientRect ( ) ;
303317 const { left : item1Left } = childElements [ 1 ] . getBoundingClientRect ( ) ;
304318 // Expect the items to have a gap of 1rem
305319 expect ( item1Left - item0Right ) . to . eql ( remValue ) ;
306320 } ) ;
307321
308- it ( 'should have a custom gap between items horizontally' , ( ) => {
322+ it ( 'should have a custom gap between items horizontally' , async ( ) => {
309323 const customGap = 10 ;
310324 setGap ( dashboard , customGap ) ;
311325 // Increase the width of the dashboard to fit two items and a gap
312326 dashboard . style . width = `${ columnWidth * 2 + customGap } px` ;
327+ await nextFrame ( ) ;
313328
314329 const { right : item0Right } = childElements [ 0 ] . getBoundingClientRect ( ) ;
315330 const { left : item1Left } = childElements [ 1 ] . getBoundingClientRect ( ) ;
316331 // Expect the items to have a gap of 10px
317332 expect ( item1Left - item0Right ) . to . eql ( customGap ) ;
318333 } ) ;
319334
320- it ( 'should have a custom gap between items vertically' , ( ) => {
335+ it ( 'should have a custom gap between items vertically' , async ( ) => {
321336 const customGap = 10 ;
322337 setGap ( dashboard , customGap ) ;
323338 dashboard . style . width = `${ columnWidth } px` ;
339+ await nextFrame ( ) ;
324340
325341 const { bottom : item0Bottom } = childElements [ 0 ] . getBoundingClientRect ( ) ;
326342 const { top : item1Top } = childElements [ 1 ] . getBoundingClientRect ( ) ;
@@ -330,8 +346,9 @@ describe('dashboard layout', () => {
330346 } ) ;
331347
332348 describe ( 'maximum column count' , ( ) => {
333- it ( 'should not limit column count by default' , ( ) => {
349+ it ( 'should not limit column count by default' , async ( ) => {
334350 dashboard . style . width = `${ columnWidth * 100 } px` ;
351+ await nextFrame ( ) ;
335352 expect ( getColumnWidths ( dashboard ) . length ) . to . eql ( 100 ) ;
336353 } ) ;
337354
0 commit comments