Skip to content

Commit 6c89778

Browse files
committed
refactor: simplify order-confirmation.test component by removing unnecessary mocks ans tests
1 parent f5b1880 commit 6c89778

File tree

1 file changed

+3
-33
lines changed

1 file changed

+3
-33
lines changed

src/routes/order-confirmation/order-confirmation.test.tsx

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ import { describe, expect, it, vi } from "vitest";
44
import OrderConfirmation from ".";
55
import type { Route } from "./+types";
66

7-
// Mock Container component
8-
vi.mock("@/components/ui", () => ({
9-
Container: vi.fn(({ children }) => (
10-
<div data-testid="mock-container">{children}</div>
11-
)),
12-
}));
13-
147
// Creates minimal test props for OrderConfirmation component
158
const createTestProps = (orderId = "test-123"): Route.ComponentProps => ({
169
loaderData: { orderId },
@@ -33,7 +26,7 @@ describe("OrderConfirmation", () => {
3326
"Llegaremos a la puerta de tu domicilio lo antes posible",
3427
];
3528
expectedMessages.forEach((message) => {
36-
expect(screen.getByText(message)).toBeInTheDocument();
29+
expect(screen.queryByText(message)).toBeInTheDocument();
3730
});
3831
});
3932
});
@@ -47,34 +40,11 @@ describe("OrderConfirmation", () => {
4740
// Step 3: Call - Render component
4841
render(<OrderConfirmation {...props} />);
4942
// Step 4: Verify - Check tracking code section
50-
const trackingCodeLabel = screen.getByText("Código de seguimiento");
43+
const trackingCodeLabel = screen.queryByText("Código de seguimiento");
5144
expect(trackingCodeLabel).toBeInTheDocument();
5245

53-
const trackingCode = screen.getByText(testOrderId);
46+
const trackingCode = screen.queryByText(testOrderId);
5447
expect(trackingCode).toBeInTheDocument();
5548
});
5649
});
57-
58-
describe("Layout Structure", () => {
59-
it("should render with correct layout structure and classes", () => {
60-
// Step 1: Setup - Create test props
61-
const props = createTestProps();
62-
// Step 2: Mock
63-
// Step 3: Call - Render component
64-
render(<OrderConfirmation {...props} />);
65-
// Step 4: Verify - Check layout structure
66-
const container = screen.getByTestId("mock-container");
67-
expect(container).toBeInTheDocument();
68-
69-
const section = container.parentElement;
70-
expect(section).toHaveClass(
71-
"pt-12",
72-
"pb-12",
73-
"sm:pt-14",
74-
"sm:pb-14",
75-
"lg:pt-16",
76-
"lg:pb-16"
77-
);
78-
});
79-
});
8050
});

0 commit comments

Comments
 (0)