Skip to content

Commit

Permalink
chore(utils): remove ResizeObserver component and useResizeObserverV1…
Browse files Browse the repository at this point in the history
… implementation

BREAKING CHANGE: Removed `ResizeObserver` component and `useResizeObserverV1` implementation
  • Loading branch information
mlaursen committed Aug 12, 2021
1 parent 216c8ef commit 6a6b109
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 690 deletions.
115 changes: 0 additions & 115 deletions packages/utils/src/sizing/ResizeObserver.tsx

This file was deleted.

30 changes: 1 addition & 29 deletions packages/utils/src/sizing/__tests__/useResizeObserver.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable no-underscore-dangle */
import React, { useRef } from "react";
import React from "react";
import { act, render } from "@testing-library/react";
import { ResizeObserver } from "@juggle/resize-observer";
import { mocked } from "ts-jest/utils";
Expand Down Expand Up @@ -113,33 +112,6 @@ describe("useResizeObserver", () => {
ResizeObserverMock.mockRestore();
});

it("should use the v1 behavior if the first arg is an object", () => {
const warn = jest.spyOn(console, "warn");
warn.mockImplementation(() => {});
const onResize = jest.fn();
const Test = () => {
const ref = useRef<HTMLDivElement | null>(null);
useResizeObserver({
onResize,
target: ref,
});
return <div ref={ref} data-testid="div" />;
};

const { getByTestId, unmount } = render(<Test />);
const div = getByTestId("div");
expect(observe).toBeCalledWith(div);
expect(observe).toBeCalledTimes(1);

unmount();
expect(observe).toBeCalledTimes(1);
expect(unobserve).toBeCalledWith(div);
expect(unobserve).toBeCalledTimes(1);
expect(disconnect).toBeCalledTimes(1);

warn.mockRestore();
});

it("should use the ref API if the first argument is a function", () => {
const onResize = jest.fn();
const Test = () => {
Expand Down
Loading

0 comments on commit 6a6b109

Please sign in to comment.