Skip to content

Commit

Permalink
Merge pull request #56 from fga-eps-mds/Teste-permission
Browse files Browse the repository at this point in the history
Teste permission
  • Loading branch information
daniso0412 authored Feb 17, 2025
2 parents 0764c2a + ddb06b1 commit 88120e8
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Components/ListComponent/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import theme from "../../Styles/global";

export default function ListComponent({ label, onClick }) {
return (
<Box sx={{ width: "100%", bgcolor: theme.palette.custom.content }}>
<Box sx={{ width: "100%", bgcolor: theme.palette.content }}>
<List component="nav" aria-label="secondary mailbox folder">
<ListItemButton onClick={onClick}>
<ListItemText primary={label} />
Expand Down
42 changes: 42 additions & 0 deletions src/Components/ListComponent/index.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { render, screen, fireEvent } from "@testing-library/react";
import { describe, it, expect, vi } from "vitest";
import ListComponent from "../ListComponent";
import { ThemeProvider } from "@mui/material/styles";
import theme from "../../Styles/global";
import '@testing-library/jest-dom';

describe("ListComponent", () => {
it("deve renderizar o label corretamente", () => {
render(
<ThemeProvider theme={theme}>
<ListComponent label="Minha Lista" onClick={vi.fn()} />
</ThemeProvider>
);

expect(screen.getByText("Minha Lista")).toBeInTheDocument();
});

it("deve chamar a função onClick quando o item da lista for clicado", () => {
const onClickMock = vi.fn();
render(
<ThemeProvider theme={theme}>
<ListComponent label="Minha Lista" onClick={onClickMock} />
</ThemeProvider>
);

fireEvent.click(screen.getByText("Minha Lista"));
expect(onClickMock).toHaveBeenCalledTimes(1);
});

it("deve ter a classe de estilo correta", () => {
render(
<ThemeProvider theme={theme}>
<ListComponent label="Minha Lista" onClick={vi.fn()} />
</ThemeProvider>
);

const listComponent = screen.getByText("Minha Lista").closest("div");
const backgroundColor = getComputedStyle(listComponent).backgroundColor;
expect(backgroundColor).toBe("rgba(0, 0, 0, 0)");
});
});
20 changes: 20 additions & 0 deletions src/Components/PayedModal/index.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { render, screen, fireEvent } from "@testing-library/react";
import { describe, it, expect, vi } from "vitest";
import PayedModal from "../PayedModal";
import "@testing-library/jest-dom";

describe("PayedModal", () => {
it("deve renderizar a mensagem corretamente", () => {
render(<PayedModal onClose={vi.fn()} />);
expect(screen.getByText("Mensalidade Quitada")).toBeInTheDocument();
});

it("deve chamar a função onClose quando o botão 'OK' for clicado", () => {
const onCloseMock = vi.fn();

render(<PayedModal onClose={onCloseMock} />);

fireEvent.click(screen.getByText("OK"));
expect(onCloseMock).toHaveBeenCalledTimes(1);
});
});

0 comments on commit 88120e8

Please sign in to comment.