Properly type Modal props to ensure useful typescript checking (#10238

* Properly type Modal props to ensure useful typescript checking

* delint

* Iterate

* Iterate

* Fix modal.close loop

* Iterate

* Fix tests

* Add comment

* Fix test
This commit is contained in:
Michael Telatyński 2023-02-28 10:31:48 +00:00 committed by GitHub
parent ae5725b24c
commit 629e5cb01f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
124 changed files with 600 additions and 560 deletions

View file

@ -38,12 +38,12 @@ describe("LinkModal", () => {
isForward: true,
};
const customRender = (isTextEnabled: boolean, onClose: () => void, isEditing = false) => {
const customRender = (isTextEnabled: boolean, onFinished: () => void, isEditing = false) => {
return render(
<LinkModal
composer={formattingFunctions}
isTextEnabled={isTextEnabled}
onClose={onClose}
onFinished={onFinished}
composerContext={{ selection: defaultValue }}
isEditing={isEditing}
/>,
@ -60,8 +60,8 @@ describe("LinkModal", () => {
it("Should create a link", async () => {
// When
const onClose = jest.fn();
customRender(false, onClose);
const onFinished = jest.fn();
customRender(false, onFinished);
// Then
expect(screen.getByLabelText("Link")).toBeTruthy();
@ -84,7 +84,7 @@ describe("LinkModal", () => {
// Then
await waitFor(() => {
expect(selectionSpy).toHaveBeenCalledWith(defaultValue);
expect(onClose).toBeCalledTimes(1);
expect(onFinished).toBeCalledTimes(1);
});
// Then
@ -93,8 +93,8 @@ describe("LinkModal", () => {
it("Should create a link with text", async () => {
// When
const onClose = jest.fn();
customRender(true, onClose);
const onFinished = jest.fn();
customRender(true, onFinished);
// Then
expect(screen.getByLabelText("Text")).toBeTruthy();
@ -127,7 +127,7 @@ describe("LinkModal", () => {
// Then
await waitFor(() => {
expect(selectionSpy).toHaveBeenCalledWith(defaultValue);
expect(onClose).toBeCalledTimes(1);
expect(onFinished).toBeCalledTimes(1);
});
// Then
@ -136,13 +136,13 @@ describe("LinkModal", () => {
it("Should remove the link", async () => {
// When
const onClose = jest.fn();
customRender(true, onClose, true);
const onFinished = jest.fn();
customRender(true, onFinished, true);
await userEvent.click(screen.getByText("Remove"));
// Then
expect(formattingFunctions.removeLinks).toHaveBeenCalledTimes(1);
expect(onClose).toBeCalledTimes(1);
expect(onFinished).toBeCalledTimes(1);
});
it("Should display the link in editing", async () => {