Skip to content

Commit

Permalink
Combobox test
Browse files Browse the repository at this point in the history
  • Loading branch information
m-akinc committed Mar 1, 2024
1 parent 3405db3 commit bfaa7e6
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/nimble-components/src/combobox/tests/combobox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,27 @@ describe('Combobox', () => {
await disconnect();
});

async function waitForSelectionUpdateAsync(): Promise<void> {
await waitForUpdatesAsync();
await waitForUpdatesAsync(); // second wait is necessary because scrolling is queued with requestAnimationFrame
}

it('should scroll the selected option into view when opened', async () => {
const { element, connect, disconnect } = await setupWithManyOptions();
await connect();
await clickAndWaitForOpen(element);

element.value = '300';
await waitForSelectionUpdateAsync();
expect(element.listbox.scrollTop).toBeGreaterThan(8000);

element.value = '0';
await waitForSelectionUpdateAsync();
expect(element.listbox.scrollTop).toBeCloseTo(4);

await disconnect();
});

it('setting open programmatically should update checked state of button', async () => {
const { element, connect, disconnect } = await setup(undefined, false);
await connect();
Expand Down

0 comments on commit bfaa7e6

Please sign in to comment.