2021-04-22 03:30:09 +00:00
|
|
|
import React from "react";
|
|
|
|
|
import { render, screen } from "test/testUtils";
|
|
|
|
|
import DynamicInputTextControl from "./DynamicInputTextControl";
|
|
|
|
|
import { reduxForm } from "redux-form";
|
|
|
|
|
import { mockCodemirrorRender } from "test/__mocks__/CodeMirrorEditorMock";
|
|
|
|
|
import userEvent from "@testing-library/user-event";
|
|
|
|
|
import { waitFor } from "@testing-library/dom";
|
|
|
|
|
|
2021-04-28 10:28:39 +00:00
|
|
|
function TestForm(props: any) {
|
|
|
|
|
return <div>{props.children}</div>;
|
|
|
|
|
}
|
2021-04-22 03:30:09 +00:00
|
|
|
|
|
|
|
|
const ReduxFormDecorator = reduxForm({
|
|
|
|
|
form: "TestForm",
|
|
|
|
|
initialValues: { actionConfiguration: { testPath: "My test value" } },
|
|
|
|
|
})(TestForm);
|
|
|
|
|
|
|
|
|
|
describe("DynamicInputTextControl", () => {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
mockCodemirrorRender();
|
|
|
|
|
});
|
|
|
|
|
it("renders correctly", () => {
|
|
|
|
|
render(
|
|
|
|
|
<ReduxFormDecorator>
|
|
|
|
|
<DynamicInputTextControl
|
|
|
|
|
actionName="Test action"
|
2021-04-28 10:28:39 +00:00
|
|
|
configProperty="actionConfiguration.testPath"
|
|
|
|
|
controlType="DYNAMIC_INPUT_TEXT_CONTROL"
|
|
|
|
|
dataType={"TABLE"}
|
2021-04-22 03:30:09 +00:00
|
|
|
formName="TestForm"
|
2021-04-28 10:28:39 +00:00
|
|
|
id={"test"}
|
|
|
|
|
isValid
|
2021-04-22 03:30:09 +00:00
|
|
|
label="Action"
|
|
|
|
|
onPropertyChange={jest.fn()}
|
|
|
|
|
placeholderText="Test placeholder"
|
|
|
|
|
/>
|
|
|
|
|
</ReduxFormDecorator>,
|
|
|
|
|
{},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const input = screen.getAllByText("My test value")[0];
|
|
|
|
|
userEvent.type(input, "New text");
|
|
|
|
|
waitFor(async () => {
|
|
|
|
|
await expect(screen.getAllByText("New text")).toHaveLength(2);
|
|
|
|
|
await expect(screen.findByText("My test value")).toBeNull();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|