feat(driver-pwa): top-up with custom keypad
Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
1 parent
d769845d88
commit
372dc0ede7
2 files changed
+108
-1
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import { describe, it, expect, vi } from "vitest";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { MemoryRouter } from "react-router-dom";
|
||||
|
||||
vi.mock("@/api/driver", () => ({
|
||||
topup: vi.fn(async () => ({ order_id: "o9", pay_url: "https://qr.nspk.ru/x", commission: 52, total: 1052 })),
|
||||
}));
|
||||
import { TopupPage } from "./TopupPage";
|
||||
import * as driver from "@/api/driver";
|
||||
|
||||
const wrap = () => render(<MemoryRouter><TopupPage /></MemoryRouter>);
|
||||
|
||||
describe("TopupPage", () => {
|
||||
it("keypad builds amount, shows total, and submits topup", async () => {
|
||||
wrap();
|
||||
await userEvent.click(screen.getByRole("button", { name: "1" }));
|
||||
await userEvent.click(screen.getByRole("button", { name: "0" }));
|
||||
await userEvent.click(screen.getByRole("button", { name: "0" }));
|
||||
await userEvent.click(screen.getByRole("button", { name: "0" }));
|
||||
expect(screen.getByTestId("amount").textContent).toBe("1 000 ₽");
|
||||
expect(screen.getByTestId("total").textContent).toContain("1 052");
|
||||
await userEvent.click(screen.getByRole("button", { name: /Оплатить/i }));
|
||||
expect(driver.topup).toHaveBeenCalledWith("Долг аренда", 1000, "qr");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user