PromucFlow_constructor/app/client/src/utils/WidgetFeatures.test.ts
Abhinav Jha 60503bb9a6
feat: Dynamic Height widget config (#13143)
* Add platform feature which adds dynamic height property controls and default properties based on widget config

* Move features to the top, so that defaults can override them if necessary

* - Add unit tests to verify that the property controls show up for dynamic height
- Add unit test to verify that the hidden hook in the dynamic height controls work
- Fix console warning for react key unavailable in Generator.tsx
- Move constants and types to their respective files

* Remove dynamic height config from Container Widget

* Add comments in hard to understand areas

* Add function which converts fn validation params to fnString
2022-04-22 15:14:22 +05:30

54 lines
1.3 KiB
TypeScript

import { RenderModes } from "constants/WidgetConstants";
import { WidgetProps } from "widgets/BaseWidget";
import {
DynamicHeight,
hideDynamicHeightPropertyControl,
} from "./WidgetFeatures";
const DUMMY_WIDGET: WidgetProps = {
bottomRow: 0,
isLoading: false,
leftColumn: 0,
parentColumnSpace: 0,
parentRowSpace: 0,
renderMode: RenderModes.CANVAS,
rightColumn: 0,
topRow: 0,
type: "SKELETON_WIDGET",
version: 2,
widgetId: "",
widgetName: "",
};
describe("Widget Features tests", () => {
it("Make sure hidden hook for dynamic Height disables if dynamic height is disabled", () => {
const inputs = [
DynamicHeight.FIXED,
"Some other value",
undefined,
null,
"hugcontents",
"hug_contents",
];
inputs.forEach((dynamicHeight) => {
const result = hideDynamicHeightPropertyControl({
...DUMMY_WIDGET,
dynamicHeight,
});
expect(result).toBe(true);
});
});
it("Make sure hidden hook for dynamic Height enabled if dynamic height is enabled", () => {
const inputs = [DynamicHeight.HUG_CONTENTS, "HUG_CONTENTS"];
inputs.forEach((dynamicHeight) => {
const result = hideDynamicHeightPropertyControl({
...DUMMY_WIDGET,
dynamicHeight,
});
expect(result).toBe(false);
});
});
});