Skip to content

Commit

Permalink
experiment create-limit-dialog test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
devinvillarosa committed Dec 11, 2024
1 parent 4c9e55d commit 52bd8d0
Showing 1 changed file with 30 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { CreateLimitDialog } from "./create-dialog";

import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { createWrapper } from "@tests/utils";
import { expect, test, vi } from "vitest";
import { beforeAll, describe, expect, it, vi } from "vitest";

import { CreateLimitDialog } from "./create-dialog";

const MOCK_DATA = {
id: "0",
Expand All @@ -14,31 +14,35 @@ const MOCK_DATA = {
active_slots: [] as Array<string>,
};

test.skip("CreateLimitDialog calls onSubmit upon entering form data", async () => {
class ResizeObserverMock {
observe() {}
unobserve() {}
disconnect() {}
}
global.ResizeObserver = ResizeObserverMock;
describe("CreateLimitDialog", () => {
beforeAll(() => {
class ResizeObserverMock {
observe() {}
unobserve() {}
disconnect() {}
}
global.ResizeObserver = ResizeObserverMock;
});
it.skip("calls onSubmit upon entering form data", async () => {
const user = userEvent.setup();

const user = userEvent.setup();
// ------------ Setup
const mockOnSubmitFn = vi.fn();
render(
<CreateLimitDialog onOpenChange={vi.fn()} onSubmit={mockOnSubmitFn} />,
{ wrapper: createWrapper() },
);

// ------------ Setup
const mockOnSubmitFn = vi.fn();
render(
<CreateLimitDialog onOpenChange={vi.fn()} onSubmit={mockOnSubmitFn} />,
{ wrapper: createWrapper() },
);
// ------------ Act
await user.type(screen.getByLabelText(/tag/i), MOCK_DATA.tag);
await user.type(
screen.getByLabelText("Concurrency Limit"),
String(MOCK_DATA.concurrency_limit),
);

// ------------ Act
await user.type(screen.getByLabelText(/tag/i), MOCK_DATA.tag);
await user.type(
screen.getByLabelText("Concurrency Limit"),
String(MOCK_DATA.concurrency_limit),
);
await user.click(screen.getByRole("button", { name: /add/i }));
await user.click(screen.getByRole("button", { name: /add/i }));

// ------------ Assert
expect(mockOnSubmitFn).toHaveBeenCalledOnce();
// ------------ Assert
expect(mockOnSubmitFn).toHaveBeenCalledOnce();
});
});

0 comments on commit 52bd8d0

Please sign in to comment.