Skip to content

Commit 0269bad

Browse files
yuriy-fixweb-padawan
authored andcommitted
Add test for resizing and navigation in RTL
1 parent 67d6d31 commit 0269bad

File tree

2 files changed

+77
-61
lines changed

2 files changed

+77
-61
lines changed

test/column-resizing.html

Lines changed: 58 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,17 @@
126126
expect(getElementFromPoint(grid, x, y)).to.equal(handle);
127127
});
128128

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();
132134

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);
135137

136-
expect(headerCells[0].clientWidth).to.equal(200);
138+
expect(headerCells[0].clientWidth).to.equal(direction === 'rtl' ? 349 : 200);
139+
});
137140
});
138141

139142
it('should not listen to track event on scroller', () => {
@@ -285,49 +288,55 @@
285288
expect(newColumn.resizable).to.be.undefined;
286289
});
287290

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+
});
331340
});
332341
});
333342

test/keyboard-navigation.html

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -706,14 +706,6 @@
706706
expect(grid.hasAttribute('navigating')).to.be.true;
707707
});
708708

709-
it('should navigate on left when navigation mode is off', () => {
710-
getRows(body)[0].children[1].focus();
711-
712-
left();
713-
714-
expect(getFocusedCellIndex()).to.equal(0);
715-
});
716-
717709
it('should enable navigation mode on right', () => {
718710
focusItem(0);
719711

@@ -722,12 +714,27 @@
722714
expect(grid.hasAttribute('navigating')).to.be.true;
723715
});
724716

725-
it('should navigate on right when navigation mode is off', () => {
726-
focusItem(0);
717+
['rtl', 'ltr'].forEach(direction => {
718+
describe(`navigation left / right in ${direction}`, () => {
719+
beforeEach(() => grid.setAttribute('dir', direction));
727720

728-
right();
721+
it('should navigate on left when navigation mode is off', () => {
722+
getRows(body)[0].children[1].focus();
729723

730-
expect(getFocusedCellIndex()).to.equal(1);
724+
left();
725+
726+
expect(getFocusedCellIndex()).to.equal(direction === 'rtl' ? 2 : 0);
727+
});
728+
729+
it('should navigate on right when navigation mode is off', () => {
730+
getRows(body)[0].children[1].focus();
731+
732+
right();
733+
734+
expect(getFocusedCellIndex()).to.equal(direction === 'rtl' ? 0 : 2);
735+
});
736+
737+
});
731738
});
732739

733740
it('should focus cell below with down', () => {

0 commit comments

Comments
 (0)