File size: 893 Bytes
fd2c364
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { vi, describe, it, expect } from "vitest";
import { ErrorState } from "#/components/features/automations/error-state";

describe("ErrorState", () => {
  it("renders error icon and retry button", () => {
    const { container } = render(<ErrorState onRetry={vi.fn()} />);

    // Check for the error icon (ExclamationCircleIcon)
    expect(container.querySelector("svg")).toBeInTheDocument();
    // Check for the retry button
    expect(screen.getByRole("button")).toBeInTheDocument();
  });

  it("calls onRetry when retry button is clicked", async () => {
    const onRetry = vi.fn();
    const user = userEvent.setup();
    render(<ErrorState onRetry={onRetry} />);

    await user.click(screen.getByRole("button"));

    expect(onRetry).toHaveBeenCalledOnce();
  });
});