Skip to content

Commit

Permalink
shared api for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gossi committed Dec 2, 2024
1 parent 5ac983c commit 09cb308
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/aria-voyager/tests/listbox/-shared.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { appendItemToList, createListElement } from '../components/list';

import type { Listbox } from '../../src';

export function withMultiSelect(list: HTMLElement): HTMLElement {
list.setAttribute('aria-multiselectable', 'true');

Expand All @@ -21,3 +23,19 @@ export function createListWithFruits() {
export function createMultiSelectListWithFruits() {
return withFruitItems(withMultiSelect(createListElement(document.body)));
}

export function getItems(list: Listbox) {
return {
firstItem: list.items[0],
secondItem: list.items[1],
thirdItem: list.items[2],
fourthItem: list.items[3],
fifthItem: list.items[4],
sixthItem: list.items[5],
// ...
fourthLastItem: list.items.at(-4) as HTMLElement,
thirdLastItem: list.items.at(-3) as HTMLElement,
secondLastItem: list.items.at(-2) as HTMLElement,
lastItem: list.items.at(-1) as HTMLElement
};
}

0 comments on commit 09cb308

Please sign in to comment.