From 959e9db2ab725c4da6356441a59c479b73f3e1e9 Mon Sep 17 00:00:00 2001 From: Jonathan Meyer <26874831+atmgrifter00@users.noreply.github.com> Date: Wed, 23 Oct 2024 10:25:25 -0500 Subject: [PATCH] More PR feedback. --- .../tabs/testing/tabs-base.pageobject.ts | 6 ++--- .../select/tests/select.foundation.spec.ts | 22 +++++++++---------- .../src/utilities/testing/component.ts | 9 ++++++++ .../src/utilities/testing/timeout.ts | 8 ------- 4 files changed, 23 insertions(+), 22 deletions(-) delete mode 100644 packages/nimble-components/src/utilities/testing/timeout.ts diff --git a/packages/nimble-components/src/patterns/tabs/testing/tabs-base.pageobject.ts b/packages/nimble-components/src/patterns/tabs/testing/tabs-base.pageobject.ts index d54ec70133..854aeac718 100644 --- a/packages/nimble-components/src/patterns/tabs/testing/tabs-base.pageobject.ts +++ b/packages/nimble-components/src/patterns/tabs/testing/tabs-base.pageobject.ts @@ -1,6 +1,6 @@ import type { Button } from '../../../button'; import { waitForUpdatesAsync } from '../../../testing/async-helpers'; -import { timeout } from '../../../utilities/testing/timeout'; +import { waitTimeout } from '../../../utilities/testing/component'; import type { TabsOwner } from '../types'; /** @@ -46,7 +46,7 @@ export abstract class TabsBasePageObject { } leftButton.click(); await waitForUpdatesAsync(); - await timeout(50); // let animation run + await waitTimeout(50); // let animation run } public async clickScrollRightButton(): Promise { @@ -58,7 +58,7 @@ export abstract class TabsBasePageObject { } rightButton.click(); await waitForUpdatesAsync(); - await timeout(50); // let animation run + await waitTimeout(50); // let animation run } public areScrollButtonsVisible(): boolean { diff --git a/packages/nimble-components/src/select/tests/select.foundation.spec.ts b/packages/nimble-components/src/select/tests/select.foundation.spec.ts index 19be279c29..4f74f5d04c 100644 --- a/packages/nimble-components/src/select/tests/select.foundation.spec.ts +++ b/packages/nimble-components/src/select/tests/select.foundation.spec.ts @@ -15,7 +15,7 @@ import { fixture } from '../../utilities/tests/fixture'; import { template } from '../template'; import { ListOption, listOptionTag } from '../../list-option'; import { template as listOptionTemplate } from '../../list-option/template'; -import { timeout } from '../../utilities/testing/timeout'; +import { waitTimeout } from '../../utilities/testing/component'; describe('Select', () => { const select = Select.compose({ @@ -422,7 +422,7 @@ describe('Select', () => { element.addEventListener('input', () => resolve(true)); element.dispatchEvent(event); }), - timeout().then(() => false) + waitTimeout().then(() => false) ]); expect(wasInput).toBeFalse(); @@ -454,7 +454,7 @@ describe('Select', () => { element.addEventListener('input', () => resolve(true)); element.dispatchEvent(event); }), - timeout().then(() => false) + waitTimeout().then(() => false) ]); expect(wasInput).toBeFalse(); @@ -482,7 +482,7 @@ describe('Select', () => { element.addEventListener('input', () => resolve(true)); element.dispatchEvent(event); }), - timeout().then(() => false) + waitTimeout().then(() => false) ]); expect(wasInput).toBeFalse(); @@ -512,7 +512,7 @@ describe('Select', () => { element.addEventListener('input', () => resolve(true)); element.dispatchEvent(event); }), - timeout().then(() => false) + waitTimeout().then(() => false) ]); expect(wasInput).toBeFalse(); @@ -672,7 +672,7 @@ describe('Select', () => { ); element.dispatchEvent(arrowUpEvent); }), - timeout().then(() => false) + waitTimeout().then(() => false) ]) ).toBeTrue(); @@ -688,7 +688,7 @@ describe('Select', () => { ); element.dispatchEvent(arrowDownEvent); }), - timeout().then(() => false) + waitTimeout().then(() => false) ]) ).toBeTrue(); @@ -719,7 +719,7 @@ describe('Select', () => { element.addEventListener('input', () => resolve(true)); element.dispatchEvent(event); }), - timeout().then(() => false) + waitTimeout().then(() => false) ]); expect(wasInput).toBeTrue(); @@ -749,7 +749,7 @@ describe('Select', () => { element.addEventListener('input', () => resolve(true)); element.dispatchEvent(event); }), - timeout().then(() => false) + waitTimeout().then(() => false) ]); expect(wasInput).toBeTrue(); @@ -779,7 +779,7 @@ describe('Select', () => { element.addEventListener('input', () => resolve(true)); element.dispatchEvent(event); }), - timeout().then(() => false) + waitTimeout().then(() => false) ]); expect(wasInput).toBeTrue(); @@ -805,7 +805,7 @@ describe('Select', () => { element.addEventListener('input', () => resolve(true)); element.dispatchEvent(event); }), - timeout().then(() => false) + waitTimeout().then(() => false) ]); expect(wasInput).toBeTrue(); diff --git a/packages/nimble-components/src/utilities/testing/component.ts b/packages/nimble-components/src/utilities/testing/component.ts index c9a7390e17..bd4129a3fb 100644 --- a/packages/nimble-components/src/utilities/testing/component.ts +++ b/packages/nimble-components/src/utilities/testing/component.ts @@ -70,3 +70,12 @@ export async function waitAnimationFrame(): Promise { requestAnimationFrame(() => resolve()); }); } + +/** + * Timeout for use in async tets. + */ +export async function waitTimeout(ms = 0): Promise { + await new Promise(resolve => { + window.setTimeout(() => resolve(undefined), ms); + }); +} \ No newline at end of file diff --git a/packages/nimble-components/src/utilities/testing/timeout.ts b/packages/nimble-components/src/utilities/testing/timeout.ts deleted file mode 100644 index d34c6073f7..0000000000 --- a/packages/nimble-components/src/utilities/testing/timeout.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Timeout for use in async tets. - */ -export async function timeout(ms = 0): Promise { - await new Promise(resolve => { - window.setTimeout(() => resolve(undefined), ms); - }); -} \ No newline at end of file