UNPKG

@payfit/unity-components

Version:

23 lines (22 loc) 1.03 kB
import { expect as e, screen as t, userEvent as n, within as r } from "storybook/test"; //#region src/components/multi-select-field/test-utils.ts var i = (i) => ({ selectOption: async ({ labelText: e, optionNames: a, container: o = i.canvasElement }) => { await i.step(`Select options "${a.join(", ")}" in "${e}"`, async () => { let i = r(o).getByLabelText(e, { exact: !1 }); if (!i) throw Error(`Multi-select not found for label ${e}`); await n.click(i, { delay: 100 }); for (let e of a) await n.click(t.getByRole("option", { name: e }), { delay: 100 }); await n.keyboard("{Escape}", { delay: 100 }); }); }, assertSelectedOptions: async ({ labelText: t, expectedDisplayValue: n, container: a = i.canvasElement }) => { await i.step(`Assert selected options "${n}" in "${t}"`, async () => { let i = r(a).getByLabelText(t, { exact: !1 }); if (!i) throw Error(`Multi-select not found for label ${t}`); await e(i).toHaveTextContent(n); }); } }); //#endregion export { i as getTestingUtilsMultiSelect };