Skip to content

Commit

Permalink
test: share a test helper between grid, grid-pro and crud (#5364) (#5375
Browse files Browse the repository at this point in the history
)

Co-authored-by: Tomi Virkki <tomivirkki@users.noreply.github.com>
  • Loading branch information
vaadin-bot and tomivirkki authored Jan 24, 2023
1 parent 0110946 commit a6643a6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 53 deletions.
20 changes: 1 addition & 19 deletions packages/crud/test/helpers.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
export const flushGrid = (grid) => {
grid._observer.flush();
if (grid._debounceScrolling) {
grid._debounceScrolling.flush();
}
if (grid._debounceScrollPeriod) {
grid._debounceScrollPeriod.flush();
}
if (grid._debouncerLoad) {
grid._debouncerLoad.flush();
}
if (grid._debounceOverflow) {
grid._debounceOverflow.flush();
}
while (grid._debounceIncreasePool) {
grid._debounceIncreasePool.flush();
grid._debounceIncreasePool = null;
}
};
export { flushGrid } from '@vaadin/grid/test/helpers.js';

export const getRows = (container) => {
return container.querySelectorAll('tr');
Expand Down
20 changes: 1 addition & 19 deletions packages/grid-pro/test/helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { isIOS } from '@vaadin/testing-helpers';
export { flushGrid } from '@vaadin/grid/test/helpers.js';

export const infiniteDataProvider = (params, callback) => {
callback(
Expand Down Expand Up @@ -82,25 +83,6 @@ export const dragAndDropOver = (source, target) => {
);
};

export const flushGrid = (grid) => {
grid._observer.flush();
if (grid._debounceScrolling) {
grid._debounceScrolling.flush();
}
grid._afterScroll();
if (grid._debounceOverflow) {
grid._debounceOverflow.flush();
}
if (grid._debouncerHiddenChanged) {
grid._debouncerHiddenChanged.flush();
}
if (grid._debouncerApplyCachedData) {
grid._debouncerApplyCachedData.flush();
}

grid.__virtualizer.flush();
};

export const getRows = (container) => {
return container.querySelectorAll('tr');
};
Expand Down
23 changes: 8 additions & 15 deletions packages/grid/test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,14 @@ import sinon from 'sinon';
export const flushGrid = (grid) => {
grid._observer.flush();
grid._afterScroll();
if (grid._debounceScrolling) {
grid._debounceScrolling.flush();
}
if (grid._debounceOverflow) {
grid._debounceOverflow.flush();
}
if (grid._debouncerHiddenChanged) {
grid._debouncerHiddenChanged.flush();
}
if (grid._debouncerApplyCachedData) {
grid._debouncerApplyCachedData.flush();
}
if (grid.__debounceUpdateFrozenColumn) {
grid.__debounceUpdateFrozenColumn.flush();
}

[
grid._debounceScrolling,
grid._debounceOverflow,
grid._debouncerHiddenChanged,
grid._debouncerApplyCachedData,
grid.__debounceUpdateFrozenColumn,
].forEach((debouncer) => debouncer?.flush());

grid.__virtualizer.flush();
};
Expand Down

0 comments on commit a6643a6

Please sign in to comment.