diff --git a/src/Explorer/Controls/SmartUi/SmartUiComponent.test.tsx b/src/Explorer/Controls/SmartUi/SmartUiComponent.test.tsx index cdb7f01a1..a6d66b631 100644 --- a/src/Explorer/Controls/SmartUi/SmartUiComponent.test.tsx +++ b/src/Explorer/Controls/SmartUi/SmartUiComponent.test.tsx @@ -107,17 +107,15 @@ describe("SmartUiComponent", () => { } }; - it("should render", done => { + it("should render", async () => { const wrapper = shallow(); - setImmediate(() => { - expect(wrapper).toMatchSnapshot(); - expect(initializeCalled).toBeTruthy(); - expect(fetchMaxCalled).toBeTruthy(); + await new Promise(resolve => setTimeout(resolve, 0)); + expect(wrapper).toMatchSnapshot(); + expect(initializeCalled).toBeTruthy(); + expect(fetchMaxCalled).toBeTruthy(); - wrapper.setState({ isRefreshing: true }); - wrapper.update(); - expect(wrapper).toMatchSnapshot(); - done(); - }); + wrapper.setState({ isRefreshing: true }); + wrapper.update(); + expect(wrapper).toMatchSnapshot(); }); }); diff --git a/src/Explorer/Controls/SmartUi/SmartUiComponent.tsx b/src/Explorer/Controls/SmartUi/SmartUiComponent.tsx index 4c524ce40..ddc61e919 100644 --- a/src/Explorer/Controls/SmartUi/SmartUiComponent.tsx +++ b/src/Explorer/Controls/SmartUi/SmartUiComponent.tsx @@ -27,6 +27,11 @@ export enum UiType { Slider = "Slider" } +type numberPromise = () => Promise; +type stringPromise = () => Promise; +type dropdownItemPromise = () => Promise; +type infoPromise = () => Promise; + /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ export type DropdownItem = { label: string; key: string }; @@ -159,7 +164,7 @@ export class SmartUiComponent extends React.Component => { if (currentNode.info && currentNode.info instanceof Function) { - currentNode.info = await (currentNode.info as Function)(); + currentNode.info = await (currentNode.info as infoPromise)(); } if (currentNode.input) { @@ -173,11 +178,11 @@ export class SmartUiComponent extends React.Component => { if (input.label instanceof Function) { - input.label = await (input.label as Function)(); + input.label = await (input.label as stringPromise)(); } if (input.placeholder instanceof Function) { - input.placeholder = await (input.placeholder as Function)(); + input.placeholder = await (input.placeholder as stringPromise)(); } switch (input.type) { @@ -187,30 +192,30 @@ export class SmartUiComponent extends React.Component { + //eslint-disable-next-line @typescript-eslint/ban-types return (target: Function) => { buildSmartUiDescriptor(target.name, target.prototype); }; }; export const ClassInfo = (info: (() => Promise) | Info): ClassDecorator => { + //eslint-disable-next-line @typescript-eslint/ban-types return (target: Function) => { addPropertyToMap(target.prototype, "root", target.name, "info", info); }; diff --git a/src/SelfServe/PropertyDecorators.tsx b/src/SelfServe/PropertyDecorators.tsx index 8899acdce..b4457366b 100644 --- a/src/SelfServe/PropertyDecorators.tsx +++ b/src/SelfServe/PropertyDecorators.tsx @@ -50,6 +50,7 @@ const addToMap = (...decorators: Decorator[]): PropertyDecorator => { let className = target.constructor.name; const propertyName = property.toString(); if (className === "Function") { + //eslint-disable-next-line @typescript-eslint/ban-types className = (target as Function).name; throw new Error(`Property '${propertyName}' in class '${className}'should be not be static.`); }