Skip to content

Commit

Permalink
move updateComplete to test helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
tomivirkki committed Dec 19, 2024
1 parent 49cd891 commit f024b28
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
12 changes: 2 additions & 10 deletions packages/dashboard/test/dashboard.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from '@vaadin/chai-plugins';
import { fixtureSync, nextFrame, nextUpdate } from '@vaadin/testing-helpers';
import { fixtureSync, nextFrame } from '@vaadin/testing-helpers';
import sinon from 'sinon';
import '../vaadin-dashboard.js';
import type { CustomElementType } from '@vaadin/component-base/src/define.js';
Expand All @@ -20,19 +20,11 @@ import {
setMinimumColumnWidth,
setMinimumRowHeight,
setSpacing,
updateComplete,
} from './helpers.js';

type TestDashboardItem = DashboardItem & { id: string; component?: Element | string };

async function updateComplete(dashboard: Dashboard<TestDashboardItem>) {
await nextUpdate(dashboard);
const widgets = dashboard.querySelectorAll('vaadin-dashboard-widget');
for (const widget of widgets) {
await nextUpdate(widget);
}
await nextFrame();
}

describe('dashboard', () => {
let dashboard: Dashboard<TestDashboardItem>;
const columnWidth = 200;
Expand Down
10 changes: 10 additions & 0 deletions packages/dashboard/test/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect } from '@vaadin/chai-plugins';
import { nextFrame, nextUpdate } from '@vaadin/testing-helpers';
import sinon from 'sinon';
import type { DashboardSection } from '../src/vaadin-dashboard-section.js';
import type { DashboardWidget } from '../src/vaadin-dashboard-widget.js';
Expand Down Expand Up @@ -374,3 +375,12 @@ function onceInvoked(object, functionName): Promise<void> {
export async function onceResized(dashboard: HTMLElement): Promise<void> {
await onceInvoked(dashboard, '_onResize');
}

export async function updateComplete(dashboard: HTMLElement): Promise<void> {
await nextUpdate(dashboard);
const widgets = dashboard.querySelectorAll('vaadin-dashboard-widget');
for (const widget of widgets) {
await nextUpdate(widget);
}
await nextFrame();
}

0 comments on commit f024b28

Please sign in to comment.