-
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.
Merge pull request #56 from fga-eps-mds/Teste-permission
Teste permission
- Loading branch information
Showing
3 changed files
with
63 additions
and
1 deletion.
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
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,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)"); | ||
}); | ||
}); |
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,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); | ||
}); | ||
}); |