|
126 | 126 | expect(getElementFromPoint(grid, x, y)).to.equal(handle);
|
127 | 127 | });
|
128 | 128 |
|
129 |
| - it('should resize on track', () => { |
130 |
| - const options = {node: handle}; |
131 |
| - const rect = headerCells[0].getBoundingClientRect(); |
| 129 | + ['rtl', 'ltr'].forEach(direction => { |
| 130 | + it(`should resize on track in ${direction}`, () => { |
| 131 | + grid.setAttribute('dir', direction); |
| 132 | + const options = {node: handle}; |
| 133 | + const rect = headerCells[0].getBoundingClientRect(); |
132 | 134 |
|
133 |
| - fire('track', {state: 'start'}, options); |
134 |
| - fire('track', {state: 'track', x: rect.left + 200, y: 0}, options); |
| 135 | + fire('track', {state: 'start'}, options); |
| 136 | + fire('track', {state: 'track', x: rect.left + (direction === 'rtl' ? -200 : 200), y: 0}, options); |
135 | 137 |
|
136 |
| - expect(headerCells[0].clientWidth).to.equal(200); |
| 138 | + expect(headerCells[0].clientWidth).to.equal(direction === 'rtl' ? 349 : 200); |
| 139 | + }); |
137 | 140 | });
|
138 | 141 |
|
139 | 142 | it('should not listen to track event on scroller', () => {
|
|
285 | 288 | expect(newColumn.resizable).to.be.undefined;
|
286 | 289 | });
|
287 | 290 |
|
288 |
| - it('should resize the child column', () => { |
289 |
| - const headerRows = getRows(grid.$.header); |
290 |
| - const handle = getRowCells(headerRows[0])[0].querySelector('[part~="resize-handle"]'); |
291 |
| - |
292 |
| - const cell = getRowCells(headerRows[1])[1]; |
293 |
| - const rect = cell.getBoundingClientRect(); |
294 |
| - const options = {node: handle}; |
295 |
| - fire('track', {state: 'start'}, options); |
296 |
| - fire('track', {state: 'track', x: rect.right + 100, y: 0}, options); |
297 |
| - |
298 |
| - expect(cell.clientWidth).to.equal(200); |
299 |
| - }); |
300 |
| - |
301 |
| - it('should resize the last non-hidden child column', () => { |
302 |
| - grid._columnTree[1][1].hidden = true; |
303 |
| - const headerRows = getRows(grid.$.header); |
304 |
| - const handle = getRowCells(headerRows[0])[0].querySelector('[part~="resize-handle"]'); |
305 |
| - |
306 |
| - const cell = getRowCells(headerRows[1])[0]; |
307 |
| - const rect = cell.getBoundingClientRect(); |
308 |
| - const options = {node: handle}; |
309 |
| - fire('track', {state: 'start'}, options); |
310 |
| - fire('track', {state: 'track', x: rect.right + 100, y: 0}, options); |
311 |
| - |
312 |
| - expect(cell.clientWidth).to.equal(200); |
313 |
| - }); |
314 |
| - |
315 |
| - it('should resize the child group\'s child column', done => { |
316 |
| - grid = fixture('group-inside-group'); |
317 |
| - grid.dataProvider = infiniteDataProvider; |
318 |
| - |
319 |
| - animationFrameFlush(() => { |
320 |
| - const headerRows = getRows(grid.$.header); |
321 |
| - const handle = getRowCells(headerRows[0])[0].querySelector('[part~="resize-handle"]'); |
322 |
| - |
323 |
| - const cell = getRowCells(headerRows[1])[1]; |
324 |
| - const rect = cell.getBoundingClientRect(); |
325 |
| - const options = {node: handle}; |
326 |
| - fire('track', {state: 'start'}, options); |
327 |
| - fire('track', {state: 'track', x: rect.right + 100, y: 0}, options); |
328 |
| - |
329 |
| - expect(cell.clientWidth).to.equal(100); |
330 |
| - done(); |
| 291 | + ['rtl', 'ltr'].forEach(direction => { |
| 292 | + describe(`child columns resizing in ${direction}`, () => { |
| 293 | + beforeEach(() => grid.setAttribute('dir', direction)); |
| 294 | + |
| 295 | + it('should resize the child column', () => { |
| 296 | + const headerRows = getRows(grid.$.header); |
| 297 | + const handle = getRowCells(headerRows[0])[0].querySelector('[part~="resize-handle"]'); |
| 298 | + |
| 299 | + const cell = getRowCells(headerRows[1])[1]; |
| 300 | + const rect = cell.getBoundingClientRect(); |
| 301 | + const options = {node: handle}; |
| 302 | + fire('track', {state: 'start'}, options); |
| 303 | + fire('track', {state: 'track', x: rect.right + (direction === 'rtl' ? -100 : 100), y: 0}, options); |
| 304 | + |
| 305 | + expect(cell.clientWidth).to.equal(direction === 'rtl' ? 100 : 200); |
| 306 | + }); |
| 307 | + |
| 308 | + it('should resize the last non-hidden child column', () => { |
| 309 | + grid._columnTree[1][1].hidden = true; |
| 310 | + const headerRows = getRows(grid.$.header); |
| 311 | + const handle = getRowCells(headerRows[0])[0].querySelector('[part~="resize-handle"]'); |
| 312 | + |
| 313 | + const cell = getRowCells(headerRows[1])[0]; |
| 314 | + const rect = cell.getBoundingClientRect(); |
| 315 | + const options = {node: handle}; |
| 316 | + fire('track', {state: 'start'}, options); |
| 317 | + fire('track', {state: 'track', x: rect.right + (direction === 'rtl' ? -100 : 100), y: 0}, options); |
| 318 | + |
| 319 | + expect(cell.clientWidth).to.equal(direction === 'rtl' ? 100 : 200); |
| 320 | + }); |
| 321 | + |
| 322 | + it('should resize the child group\'s child column', done => { |
| 323 | + grid = fixture('group-inside-group'); |
| 324 | + grid.dataProvider = infiniteDataProvider; |
| 325 | + |
| 326 | + animationFrameFlush(() => { |
| 327 | + const headerRows = getRows(grid.$.header); |
| 328 | + const handle = getRowCells(headerRows[0])[0].querySelector('[part~="resize-handle"]'); |
| 329 | + |
| 330 | + const cell = getRowCells(headerRows[1])[1]; |
| 331 | + const rect = cell.getBoundingClientRect(); |
| 332 | + const options = {node: handle}; |
| 333 | + fire('track', {state: 'start'}, options); |
| 334 | + fire('track', {state: 'track', x: rect.right + 100, y: 0}, options); |
| 335 | + |
| 336 | + expect(cell.clientWidth).to.equal(100); |
| 337 | + done(); |
| 338 | + }); |
| 339 | + }); |
331 | 340 | });
|
332 | 341 | });
|
333 | 342 |
|
|
0 commit comments