-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { render, screen, fireEvent } from "@testing-library/react"; | ||
import { describe, it, expect, vi } from "vitest"; | ||
import { ErrorDialog } from "./Error"; | ||
import "@testing-library/jest-dom"; | ||
import { mockDialogFn, RECEIPT } from "./helper"; | ||
|
||
describe("ErrorDialog", () => { | ||
beforeAll(mockDialogFn); | ||
const ADDRESS = "0x2cc017e8cd08a2f949fc0a1903ea21a8387f2834"; | ||
|
||
it("should show the dialog when open is true", () => { | ||
render(<ErrorDialog open={true} address={ADDRESS} />); | ||
|
||
const dialog = screen.getByRole("dialog"); | ||
expect(dialog).toBeVisible(); | ||
}); | ||
|
||
it("should close the dialog when open is false", () => { | ||
render(<ErrorDialog open={false} address={ADDRESS} />); | ||
|
||
const dialog = screen.queryByRole("dialog"); | ||
// Note: closed dialog might not be in the DOM, hence using queryByRole | ||
expect(dialog).toBe(null); | ||
}); | ||
|
||
it("should contain the transaction link with the correct URL", () => { | ||
render(<ErrorDialog open={true} address={ADDRESS} />); | ||
|
||
const link = screen.getByText(/Arbitrum Scan/i); | ||
expect(link).toBeInTheDocument(); | ||
expect(link).toHaveAttribute( | ||
"href", | ||
`https://arbiscan.io/address/${ADDRESS}` | ||
); | ||
}); | ||
|
||
it("should close the dialog when the Close button is clicked", () => { | ||
render(<ErrorDialog open={true} address={ADDRESS} />); | ||
|
||
const closeButton = screen.getByText(/Close/i); | ||
fireEvent.click(closeButton); | ||
|
||
const dialog = screen.queryByRole("dialog"); | ||
expect(dialog).toBe(null); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters