Skip to content

Commit

Permalink
Fix jsdom tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mj12albert committed Oct 29, 2024
1 parent ec8d70b commit faf9231
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions packages/mui-base/src/Accordion/Root/AccordionRoot.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as React from 'react';
import { expect } from 'chai';
import { spy } from 'sinon';
import { createRenderer, describeSkipIf } from '@mui/internal-test-utils';
import { Accordion } from '@base_ui/react/Accordion';
import { describeConformance, createRenderer } from '#test-utils';
import { describeConformance } from '#test-utils';

describe('<Accordion.Root />', () => {
const { render } = createRenderer();
Expand Down Expand Up @@ -41,7 +42,13 @@ describe('<Accordion.Root />', () => {
});

describe('uncontrolled', () => {
it('open state', async () => {
it('open state', async function test(t = {}) {
if (/jsdom/.test(window.navigator.userAgent)) {
// @ts-expect-error to support mocha and vitest
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
this?.skip?.() || t?.skip();
}

const { getByRole, queryByText, user } = await render(
<Accordion.Root data-testid="root" animated={false}>
<Accordion.Item>
Expand Down Expand Up @@ -283,7 +290,7 @@ describe('<Accordion.Root />', () => {
});
});

describe('keyboard interactions', () => {
describeSkipIf(/jsdom/.test(window.navigator.userAgent))('keyboard interactions', () => {
['Enter', 'Space'].forEach((key) => {
it(`key: ${key} toggles the Accordion open state`, async () => {
const { getByRole, queryByText, user } = await render(
Expand Down Expand Up @@ -510,7 +517,7 @@ describe('<Accordion.Root />', () => {
});
});

describe('prop: openMultiple', () => {
describeSkipIf(/jsdom/.test(window.navigator.userAgent))('prop: openMultiple', () => {
it('multiple items can be open by default', async () => {
const { getByTestId, queryByText, user } = await render(
<Accordion.Root animated={false}>
Expand Down Expand Up @@ -589,7 +596,7 @@ describe('<Accordion.Root />', () => {
});
});

describe('horizontal orientation', () => {
describeSkipIf(/jsdom/.test(window.navigator.userAgent))('horizontal orientation', () => {
it('ArrowLeft/Right moves focus in horizontal orientation', async () => {
const { getByTestId, user } = await render(
<Accordion.Root animated={false} orientation="horizontal">
Expand Down Expand Up @@ -627,7 +634,7 @@ describe('<Accordion.Root />', () => {
expect(trigger1).toHaveFocus();
});

describe('RTL', () => {
describeSkipIf(/jsdom/.test(window.navigator.userAgent))('RTL', () => {
it('ArrowLeft/Right is reversed for horizontal accordions in RTL mode', async () => {
const { getByTestId, user } = await render(
<Accordion.Root animated={false} orientation="horizontal" direction="rtl">
Expand Down Expand Up @@ -667,7 +674,7 @@ describe('<Accordion.Root />', () => {
});
});

describe('prop: onValueChange', () => {
describeSkipIf(/jsdom/.test(window.navigator.userAgent))('prop: onValueChange', () => {
it('default item value', async () => {
const onValueChange = spy();

Expand Down

0 comments on commit faf9231

Please sign in to comment.