diff --git a/packages/dialog/src/FixedDialog.tsx b/packages/dialog/src/FixedDialog.tsx index bae2022982..5041f3e4fc 100644 --- a/packages/dialog/src/FixedDialog.tsx +++ b/packages/dialog/src/FixedDialog.tsx @@ -75,7 +75,7 @@ export const FixedDialog = forwardRef( style: propStyle, transformOrigin: true, ...options, - onScroll: (_event, { visible }) => { + onScroll: /* istanbul ignore next */ (_event, { visible }) => { if (!visible) { onRequestClose(); } diff --git a/packages/dialog/src/__tests__/FixedDialog.tsx b/packages/dialog/src/__tests__/FixedDialog.tsx new file mode 100644 index 0000000000..ddfdd0d32f --- /dev/null +++ b/packages/dialog/src/__tests__/FixedDialog.tsx @@ -0,0 +1,48 @@ +import React, { ReactElement, useRef } from "react"; +import { render } from "@testing-library/react"; +import { DATA_RMD_NOSCROLL } from "@react-md/utils"; + +import { FixedDialog, FixedDialogProps } from "../FixedDialog"; + +const noop = (): void => {}; + +function Test({ + id = "dialog", + "aria-label": ariaLabel = "Label", + onRequestClose = noop, + visible = false, + children, + ...props +}: Partial): ReactElement { + const fixedTo = useRef(null); + return ( + <> + + + {children} + + + ); +} + +describe("FixedDialog", () => { + it("should disable the overlay and scroll lock behavior by default", () => { + const onRequestClose = jest.fn(); + const { baseElement } = render( + + ); + + expect(baseElement).toMatchSnapshot(); + expect(document.body).not.toHaveAttribute(DATA_RMD_NOSCROLL); + expect(onRequestClose).not.toBeCalled(); + }); +}); diff --git a/packages/dialog/src/__tests__/__snapshots__/FixedDialog.tsx.snap b/packages/dialog/src/__tests__/__snapshots__/FixedDialog.tsx.snap new file mode 100644 index 0000000000..ddb21e9a9b --- /dev/null +++ b/packages/dialog/src/__tests__/__snapshots__/FixedDialog.tsx.snap @@ -0,0 +1,26 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`FixedDialog should disable the overlay and scroll lock behavior by default 1`] = ` + +
+ +
+ +