Skip to content

Commit

Permalink
web: Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tbantle22 committed Oct 12, 2023
1 parent 86d12ec commit fedb1d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 8 additions & 3 deletions packages/web/components/DocMarkdown/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { MockedProvider } from "@apollo/client/testing";
import { DocType } from "@gen/graphql-types";
import useMockRouter from "@hooks/useMockRouter";
import useMockRouter, { actions } from "@hooks/useMockRouter";
import { RefParams } from "@lib/params";
import { setup } from "@lib/testUtils.test";
import { sqlQuery } from "@lib/urls";
import { getDoc } from "@pageComponents/DatabasePage/ForDocs/DocList/mocks";
import { render, screen } from "@testing-library/react";
import { render, screen, waitFor } from "@testing-library/react";
import DocMarkdown from ".";

const jestRouter = jest.spyOn(require("next/router"), "useRouter");
Expand Down Expand Up @@ -122,6 +123,10 @@ describe("test DocMarkdown", () => {
expect(screen.getByLabelText("markdown-editor")).toBeVisible();

await user.click(screen.getByText("delete"));
expect(screen.getByText(`Delete ${docName}`)).toBeVisible();
const { href, as } = sqlQuery({
...params,
q: `DELETE FROM dolt_docs WHERE doc_name="${docName}"`,
});
await waitFor(() => expect(actions.push).toHaveBeenCalledWith(href, as));
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { MockedProvider } from "@apollo/client/testing";
import { DocType } from "@gen/graphql-types";
import { getDocsQuery } from "@hooks/useEditDoc/utils";
import useMockRouter, { actions } from "@hooks/useMockRouter";
import { RefParams } from "@lib/params";
import { setup } from "@lib/testUtils.test";
Expand Down Expand Up @@ -50,7 +48,7 @@ describe("test NewDocForm", () => {

const { href, as } = sqlQuery({
...params,
q: getDocsQuery(DocType.License, markdown),
q: `INSERT INTO dolt_docs VALUES ("LICENSE.md", "${markdown}") ON DUPLICATE KEY UPDATE doc_text="${markdown}"`,
});
await waitFor(() => expect(actions.push).toHaveBeenCalledWith(href, as));
});
Expand Down

0 comments on commit fedb1d8

Please sign in to comment.