Skip to content

Commit

Permalink
Modify Portal tests
Browse files Browse the repository at this point in the history
  • Loading branch information
atomiks committed Dec 4, 2024
1 parent bef0861 commit aa86ee0
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 77 deletions.
2 changes: 2 additions & 0 deletions docs/data/api/alert-dialog-portal.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"import { AlertDialog } from '@base-ui-components/react/alert-dialog';\nconst AlertDialogPortal = AlertDialog.Portal;"
],
"classes": [],
"spread": true,
"themeDefaultProps": null,
"muiName": "AlertDialogPortal",
"filename": "/packages/react/src/alert-dialog/portal/AlertDialogPortal.tsx",
"inheritance": null,
Expand Down
2 changes: 2 additions & 0 deletions docs/data/api/dialog-portal.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"import { Dialog } from '@base-ui-components/react/dialog';\nconst DialogPortal = Dialog.Portal;"
],
"classes": [],
"spread": true,
"themeDefaultProps": null,
"muiName": "DialogPortal",
"filename": "/packages/react/src/dialog/portal/DialogPortal.tsx",
"inheritance": null,
Expand Down
2 changes: 2 additions & 0 deletions docs/data/api/menu-portal.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"import { Menu } from '@base-ui-components/react/menu';\nconst MenuPortal = Menu.Portal;"
],
"classes": [],
"spread": true,
"themeDefaultProps": null,
"muiName": "MenuPortal",
"filename": "/packages/react/src/menu/portal/MenuPortal.tsx",
"inheritance": null,
Expand Down
2 changes: 2 additions & 0 deletions docs/data/api/popover-portal.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"import { Popover } from '@base-ui-components/react/popover';\nconst PopoverPortal = Popover.Portal;"
],
"classes": [],
"spread": true,
"themeDefaultProps": null,
"muiName": "PopoverPortal",
"filename": "/packages/react/src/popover/portal/PopoverPortal.tsx",
"inheritance": null,
Expand Down
2 changes: 2 additions & 0 deletions docs/data/api/preview-card-portal.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"import { PreviewCard } from '@base-ui-components/react/preview-card';\nconst PreviewCardPortal = PreviewCard.Portal;"
],
"classes": [],
"spread": true,
"themeDefaultProps": null,
"muiName": "PreviewCardPortal",
"filename": "/packages/react/src/preview-card/portal/PreviewCardPortal.tsx",
"inheritance": null,
Expand Down
2 changes: 2 additions & 0 deletions docs/data/api/select-portal.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"import { Select } from '@base-ui-components/react/select';\nconst SelectPortal = Select.Portal;"
],
"classes": [],
"spread": true,
"themeDefaultProps": null,
"muiName": "SelectPortal",
"filename": "/packages/react/src/select/portal/SelectPortal.tsx",
"inheritance": null,
Expand Down
2 changes: 2 additions & 0 deletions docs/data/api/tooltip-portal.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"import { Tooltip } from '@base-ui-components/react/tooltip';\nconst TooltipPortal = Tooltip.Portal;"
],
"classes": [],
"spread": true,
"themeDefaultProps": null,
"muiName": "TooltipPortal",
"filename": "/packages/react/src/tooltip/portal/TooltipPortal.tsx",
"inheritance": null,
Expand Down
24 changes: 13 additions & 11 deletions packages/react/src/alert-dialog/portal/AlertDialogPortal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import * as React from 'react';
import { AlertDialog } from '@base-ui-components/react/alert-dialog';
import { createRenderer, describeConformance } from '#test-utils';
import { screen } from '@mui/internal-test-utils';
import { createRenderer } from '#test-utils';
import { expect } from 'chai';

describe('<AlertDialog.Portal />', () => {
const { render } = createRenderer();

describeConformance(<AlertDialog.Portal />, () => ({
refInstanceof: null,
render(node) {
return render(
<AlertDialog.Root open animated={false}>
{node}
</AlertDialog.Root>,
);
},
}));
it('renders children', async () => {
await render(
<AlertDialog.Root open>
<AlertDialog.Portal data-testid="portal">
<AlertDialog.Popup data-testid="popup" />
</AlertDialog.Portal>
</AlertDialog.Root>,
);
expect(screen.getByTestId('popup')).not.to.equal(null);
});
});
24 changes: 13 additions & 11 deletions packages/react/src/dialog/portal/DialogPortal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import * as React from 'react';
import { Dialog } from '@base-ui-components/react/dialog';
import { createRenderer, describeConformance } from '#test-utils';
import { screen } from '@mui/internal-test-utils';
import { createRenderer } from '#test-utils';
import { expect } from 'chai';

describe('<Dialog.Portal />', () => {
const { render } = createRenderer();

describeConformance(<Dialog.Portal />, () => ({
refInstanceof: null,
render(node) {
return render(
<Dialog.Root open animated={false}>
{node}
</Dialog.Root>,
);
},
}));
it('renders children', async () => {
await render(
<Dialog.Root open>
<Dialog.Portal data-testid="portal">
<Dialog.Popup data-testid="popup" />
</Dialog.Portal>
</Dialog.Root>,
);
expect(screen.getByTestId('popup')).not.to.equal(null);
});
});
24 changes: 13 additions & 11 deletions packages/react/src/menu/portal/MenuPortal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import * as React from 'react';
import { Menu } from '@base-ui-components/react/menu';
import { createRenderer, describeConformance } from '#test-utils';
import { screen } from '@mui/internal-test-utils';
import { createRenderer } from '#test-utils';
import { expect } from 'chai';

describe('<Menu.Portal />', () => {
const { render } = createRenderer();

describeConformance(<Menu.Portal />, () => ({
refInstanceof: null,
render(node) {
return render(
<Menu.Root open animated={false}>
{node}
</Menu.Root>,
);
},
}));
it('renders children', async () => {
await render(
<Menu.Root open>
<Menu.Portal data-testid="portal">
<Menu.Positioner data-testid="positioner" />
</Menu.Portal>
</Menu.Root>,
);
expect(screen.getByTestId('positioner')).not.to.equal(null);
});
});
24 changes: 13 additions & 11 deletions packages/react/src/popover/portal/PopoverPortal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import * as React from 'react';
import { Popover } from '@base-ui-components/react/popover';
import { createRenderer, describeConformance } from '#test-utils';
import { screen } from '@mui/internal-test-utils';
import { createRenderer } from '#test-utils';
import { expect } from 'chai';

describe('<Popover.Portal />', () => {
const { render } = createRenderer();

describeConformance(<Popover.Portal />, () => ({
refInstanceof: null,
render(node) {
return render(
<Popover.Root open animated={false}>
{node}
</Popover.Root>,
);
},
}));
it('renders children', async () => {
await render(
<Popover.Root open>
<Popover.Portal data-testid="portal">
<Popover.Positioner data-testid="positioner" />
</Popover.Portal>
</Popover.Root>,
);
expect(screen.getByTestId('positioner')).not.to.equal(null);
});
});
24 changes: 13 additions & 11 deletions packages/react/src/preview-card/portal/PreviewCardPortal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import * as React from 'react';
import { PreviewCard } from '@base-ui-components/react/preview-card';
import { createRenderer, describeConformance } from '#test-utils';
import { screen } from '@mui/internal-test-utils';
import { createRenderer } from '#test-utils';
import { expect } from 'chai';

describe('<PreviewCard.Portal />', () => {
const { render } = createRenderer();

describeConformance(<PreviewCard.Portal />, () => ({
refInstanceof: null,
render(node) {
return render(
<PreviewCard.Root open animated={false}>
{node}
</PreviewCard.Root>,
);
},
}));
it('renders children', async () => {
await render(
<PreviewCard.Root open>
<PreviewCard.Portal data-testid="portal">
<PreviewCard.Positioner data-testid="positioner" />
</PreviewCard.Portal>
</PreviewCard.Root>,
);
expect(screen.getByTestId('positioner')).not.to.equal(null);
});
});
24 changes: 13 additions & 11 deletions packages/react/src/select/portal/SelectPortal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import * as React from 'react';
import { Select } from '@base-ui-components/react/select';
import { createRenderer, describeConformance } from '#test-utils';
import { screen } from '@mui/internal-test-utils';
import { createRenderer } from '#test-utils';
import { expect } from 'chai';

describe('<Select.Portal />', () => {
const { render } = createRenderer();

describeConformance(<Select.Portal />, () => ({
refInstanceof: null,
render(node) {
return render(
<Select.Root open animated={false}>
{node}
</Select.Root>,
);
},
}));
it('renders children', async () => {
await render(
<Select.Root open>
<Select.Portal data-testid="portal">
<Select.Positioner data-testid="positioner" />
</Select.Portal>
</Select.Root>,
);
expect(screen.getByTestId('positioner')).not.to.equal(null);
});
});
24 changes: 13 additions & 11 deletions packages/react/src/tooltip/portal/TooltipPortal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import * as React from 'react';
import { Tooltip } from '@base-ui-components/react/tooltip';
import { createRenderer, describeConformance } from '#test-utils';
import { screen } from '@mui/internal-test-utils';
import { createRenderer } from '#test-utils';
import { expect } from 'chai';

describe('<Tooltip.Portal />', () => {
const { render } = createRenderer();

describeConformance(<Tooltip.Portal />, () => ({
refInstanceof: null,
render(node) {
return render(
<Tooltip.Root open animated={false}>
{node}
</Tooltip.Root>,
);
},
}));
it('renders children', async () => {
await render(
<Tooltip.Root open>
<Tooltip.Portal data-testid="portal">
<Tooltip.Positioner data-testid="positioner" />
</Tooltip.Portal>
</Tooltip.Root>,
);
expect(screen.getByTestId('positioner')).not.to.equal(null);
});
});

0 comments on commit aa86ee0

Please sign in to comment.