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:
parent
ae5725b24c
commit
629e5cb01f
124 changed files with 600 additions and 560 deletions
|
@ -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 () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue