* 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
54 lines
1.3 KiB
TypeScript
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);
|
|
});
|
|
});
|
|
});
|