Skip to content

Commit

Permalink
Add tests to various hooks (#16293)
Browse files Browse the repository at this point in the history
* Move testutils to test-utils folder

* Add mock data

* Add analytics provider to test renderer

* Add hooks.test.ts, test useUniqueFormId

* Add tests for mapFormPropsToOperation and useInitialValues
  • Loading branch information
krishnaglick committed Sep 7, 2022
1 parent 4e7ba06 commit bc0d7cc
Show file tree
Hide file tree
Showing 14 changed files with 4,072 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from "utils/testutils";
import { render } from "test-utils/testutils";

import { EditorHeader } from "./EditorHeader";

Expand Down
3 changes: 1 addition & 2 deletions airbyte-webapp/src/components/base/Input/Input.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { fireEvent, waitFor } from "@testing-library/react";
import { act } from "react-dom/test-utils";

import { render } from "utils/testutils";
import { render } from "test-utils/testutils";

import { Input } from "./Input";

Expand Down
19 changes: 19 additions & 0 deletions airbyte-webapp/src/hooks/services/FormChangeTracker/hooks.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { renderHook } from "@testing-library/react-hooks";

import { useUniqueFormId } from "./hooks";

describe("#useUniqueFormId", () => {
it("should use what is passed into it", () => {
const {
result: { current },
} = renderHook(() => useUniqueFormId("asdf"));
expect(current).toBe("asdf");
});

it("should generate an id like /form_/", () => {
const {
result: { current },
} = renderHook(useUniqueFormId);
expect(current).toMatch(/form_/);
});
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { render, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { useEffectOnce } from "react-use";

import { useMockIntersectionObserver } from "utils/testutils";
import { useMockIntersectionObserver } from "test-utils/testutils";

import { ModalServiceProvider, useModalService } from "./ModalService";
import { ModalResult } from "./types";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { render } from "@testing-library/react";
import userEvents from "@testing-library/user-event";
import { EMPTY } from "rxjs";
import { TestWrapper } from "test-utils/testutils";

import type { useExperiment } from "hooks/services/Experiment";
import type { Experiments } from "hooks/services/Experiment/experiments";
import { TestWrapper } from "utils/testutils";

const mockUseExperiment = jest.fn<ReturnType<typeof useExperiment>, Parameters<typeof useExperiment>>();
jest.doMock("hooks/services/Experiment", () => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render, mockConnection } from "utils/testutils";
import { render, mockConnection } from "test-utils/testutils";

import SettingsView from "./SettingsView";

Expand Down

0 comments on commit bc0d7cc

Please sign in to comment.