import { CheckboxUniDriver } from '@wix/design-system/dist/testkit/unidriver';
import { UniDriver } from '@wix/wix-ui-test-utils/unidriver';

export function MultiInlineCheckboxUniDriver(base: UniDriver, body: UniDriver) {
  const getCheckboxById = (id: string) =>
    CheckboxUniDriver(
      base.$(`[data-hook="multi-inline-checkbox-${id}"]`),
      body,
    );

  const getCheckboxAt = (index: number) =>
    CheckboxUniDriver(base.$$(':scope > *').get(index), body);

  const checkOptions = async (ids: string[]) => {
    await Promise.all(ids.map((id) => getCheckboxById(id).click()));
  };

  const getCheckboxesCount = () => base.$$(':scope > *').count();

  return {
    checkOptions,
    getCheckboxAt,
    getCheckboxById,
    getCheckboxesCount,
  };
}
