forked from liftedinit/manifest-app
-
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
3 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
components/admins/components/__tests__/adminOptions.test.tsx
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,58 @@ | ||
import { afterEach, describe, expect, test } from "bun:test"; | ||
import React from "react"; | ||
import { screen, cleanup, within } from "@testing-library/react"; | ||
import AdminOptions from "@/components/admins/components/adminOptions"; | ||
import matchers from "@testing-library/jest-dom/matchers"; | ||
import { renderWithChainProvider } from "@/tests/render"; | ||
import { mockPoaParams, mockGroup } from "@/tests/mock"; | ||
|
||
expect.extend(matchers); | ||
|
||
const renderWithProps = (props = {}) => { | ||
const defaultProps = { | ||
poaParams: mockPoaParams, | ||
group: mockGroup, | ||
isLoading: false, | ||
address: "test_address", | ||
admin: "admin1", | ||
}; | ||
return renderWithChainProvider(<AdminOptions {...defaultProps} {...props} />); | ||
}; | ||
|
||
describe("AdminOptions", () => { | ||
afterEach(cleanup); | ||
|
||
test("renders loading state correctly", () => { | ||
renderWithProps({ isLoading: true }); | ||
expect(screen.getByText("Admin")).toBeInTheDocument(); | ||
}); | ||
|
||
test("renders admin details correctly when not loading", () => { | ||
renderWithProps(); | ||
expect(screen.getByText("Admin")).toBeInTheDocument(); | ||
expect(screen.getByAltText("Profile Avatar")).toBeInTheDocument(); | ||
const titleContainer = screen.getByLabelText("title"); | ||
expect(within(titleContainer).getByText("title1")).toBeInTheDocument(); | ||
const detailsContainer = screen.getByLabelText("details"); | ||
expect(within(detailsContainer).getByText("details1")).toBeInTheDocument(); | ||
}); | ||
|
||
test("opens update modal on button click", () => { | ||
renderWithProps(); | ||
const updateAdminButtonContainer = screen.getByLabelText("update admin"); | ||
const updateButton = within(updateAdminButtonContainer).getByText("Update Admin"); | ||
updateButton.click(); | ||
const modal = document.getElementById("update-admin-modal") as HTMLDialogElement; | ||
expect(modal).toBeInTheDocument(); | ||
expect(modal.open).toBe(true); | ||
}); | ||
|
||
test("opens description modal on button click", () => { | ||
renderWithProps(); | ||
const descriptionButton = screen.getByLabelText("three-dots"); | ||
descriptionButton.click(); | ||
const modal = document.getElementById("description-modal") as HTMLDialogElement; | ||
expect(modal).toBeInTheDocument(); | ||
expect(modal.open).toBe(true); | ||
}); | ||
}); |
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
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