Skip to content

Commit

Permalink
More PR feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
atmgrifter00 committed Oct 23, 2024
1 parent ee1486f commit 959e9db
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -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';

/**
Expand Down Expand Up @@ -46,7 +46,7 @@ export abstract class TabsBasePageObject<T extends TabsOwner> {
}
leftButton.click();
await waitForUpdatesAsync();
await timeout(50); // let animation run
await waitTimeout(50); // let animation run
}

public async clickScrollRightButton(): Promise<void> {
Expand All @@ -58,7 +58,7 @@ export abstract class TabsBasePageObject<T extends TabsOwner> {
}
rightButton.click();
await waitForUpdatesAsync();
await timeout(50); // let animation run
await waitTimeout(50); // let animation run
}

public areScrollButtonsVisible(): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -422,7 +422,7 @@ describe('Select', () => {
element.addEventListener('input', () => resolve(true));
element.dispatchEvent(event);
}),
timeout().then(() => false)
waitTimeout().then(() => false)
]);

expect(wasInput).toBeFalse();
Expand Down Expand Up @@ -454,7 +454,7 @@ describe('Select', () => {
element.addEventListener('input', () => resolve(true));
element.dispatchEvent(event);
}),
timeout().then(() => false)
waitTimeout().then(() => false)
]);

expect(wasInput).toBeFalse();
Expand Down Expand Up @@ -482,7 +482,7 @@ describe('Select', () => {
element.addEventListener('input', () => resolve(true));
element.dispatchEvent(event);
}),
timeout().then(() => false)
waitTimeout().then(() => false)
]);

expect(wasInput).toBeFalse();
Expand Down Expand Up @@ -512,7 +512,7 @@ describe('Select', () => {
element.addEventListener('input', () => resolve(true));
element.dispatchEvent(event);
}),
timeout().then(() => false)
waitTimeout().then(() => false)
]);

expect(wasInput).toBeFalse();
Expand Down Expand Up @@ -672,7 +672,7 @@ describe('Select', () => {
);
element.dispatchEvent(arrowUpEvent);
}),
timeout().then(() => false)
waitTimeout().then(() => false)
])
).toBeTrue();

Expand All @@ -688,7 +688,7 @@ describe('Select', () => {
);
element.dispatchEvent(arrowDownEvent);
}),
timeout().then(() => false)
waitTimeout().then(() => false)
])
).toBeTrue();

Expand Down Expand Up @@ -719,7 +719,7 @@ describe('Select', () => {
element.addEventListener('input', () => resolve(true));
element.dispatchEvent(event);
}),
timeout().then(() => false)
waitTimeout().then(() => false)
]);

expect(wasInput).toBeTrue();
Expand Down Expand Up @@ -749,7 +749,7 @@ describe('Select', () => {
element.addEventListener('input', () => resolve(true));
element.dispatchEvent(event);
}),
timeout().then(() => false)
waitTimeout().then(() => false)
]);

expect(wasInput).toBeTrue();
Expand Down Expand Up @@ -779,7 +779,7 @@ describe('Select', () => {
element.addEventListener('input', () => resolve(true));
element.dispatchEvent(event);
}),
timeout().then(() => false)
waitTimeout().then(() => false)
]);

expect(wasInput).toBeTrue();
Expand All @@ -805,7 +805,7 @@ describe('Select', () => {
element.addEventListener('input', () => resolve(true));
element.dispatchEvent(event);
}),
timeout().then(() => false)
waitTimeout().then(() => false)
]);

expect(wasInput).toBeTrue();
Expand Down
9 changes: 9 additions & 0 deletions packages/nimble-components/src/utilities/testing/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,12 @@ export async function waitAnimationFrame(): Promise<void> {
requestAnimationFrame(() => resolve());
});
}

/**
* Timeout for use in async tets.
*/
export async function waitTimeout(ms = 0): Promise<void> {
await new Promise(resolve => {
window.setTimeout(() => resolve(undefined), ms);
});
}
8 changes: 0 additions & 8 deletions packages/nimble-components/src/utilities/testing/timeout.ts

This file was deleted.

0 comments on commit 959e9db

Please sign in to comment.