PromucFlow_constructor/app/client/src/selectors/widgetSelectors.test.tsx
ankurrsinghal 0de6643922
fix: auto height limits container select (#18546)
* fixed the issue of parent container select while changing the auto height with limits by adding one more check in the clickToSelectWidget hook

* added a unit test to test shouldWidgetIgnoreClicksSelector based on whether we are changing the auto height with limits

* fixed the failing tests

Co-authored-by: Ankur Singhal <ankurrsinghal@gmail.com>
2022-11-30 13:02:36 +05:30

28 lines
990 B
TypeScript

import React from "react";
import { Provider, useSelector } from "react-redux";
import { shouldWidgetIgnoreClicksSelector } from "./widgetSelectors";
import { renderHook, act } from "@testing-library/react-hooks";
import store from "../store";
import { useAutoHeightUIState } from "utils/hooks/autoHeightUIHooks";
describe("shouldWidgetIgnoreClicksSelector", () => {
it("should return true when we are changing the auto height with limits", () => {
const wrapper = ({ children }: { children: React.ReactNode }) => (
<Provider store={store}>{children}</Provider>
);
const { result: shouldIgnore } = renderHook(
() => useSelector(shouldWidgetIgnoreClicksSelector("0")),
{ wrapper },
);
const { result: autoHeightUIState } = renderHook(
() => useAutoHeightUIState(),
{ wrapper },
);
act(() => {
autoHeightUIState.current.setIsAutoHeightWithLimitsChanging(true);
});
expect(shouldIgnore.current).toBe(true);
});
});