-
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 #530 from CBIIT/fix-css-import
fix: Remove directly imported CSS
- Loading branch information
Showing
5 changed files
with
107 additions
and
67 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
File renamed without changes
This file was deleted.
Oops, something went wrong.
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,50 @@ | ||
import { fireEvent, render, waitFor } from "@testing-library/react"; | ||
import { axe } from "jest-axe"; | ||
import ScrollButton from "./ScrollButtonView"; | ||
|
||
describe("Accessibility", () => { | ||
it("should not have accessibility violations", async () => { | ||
const { container } = render(<ScrollButton />); | ||
expect(await axe(container)).toHaveNoViolations(); | ||
}); | ||
}); | ||
|
||
describe("Basic Functionality", () => { | ||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it("should be hidden by default", () => { | ||
const { getByTestId } = render(<ScrollButton />); | ||
|
||
expect(getByTestId("scroll-top-button")).toBeInTheDocument(); | ||
expect(getByTestId("scroll-top-button")).not.toBeVisible(); | ||
}); | ||
|
||
it("should only appear when the user scrolls down", async () => { | ||
const { getByTestId } = render(<ScrollButton />); | ||
|
||
// TOP | ||
expect(getByTestId("scroll-top-button")).not.toBeVisible(); | ||
expect(getByTestId("scroll-top-button")).toBeInTheDocument(); | ||
|
||
// SCROLL DOWN | ||
fireEvent.scroll(window, { target: { scrollY: 300 } }); | ||
await waitFor(() => expect(getByTestId("scroll-top-button")).toBeVisible()); | ||
|
||
// SCROLL UP | ||
fireEvent.scroll(window, { target: { scrollY: 0 } }); | ||
await waitFor(() => expect(getByTestId("scroll-top-button")).not.toBeVisible()); | ||
}); | ||
|
||
it("should scroll to the top of the page when clicked", () => { | ||
window.scrollTo = jest.fn(); | ||
|
||
const { getByTestId } = render(<ScrollButton />); | ||
|
||
fireEvent.scroll(window, { target: { scrollY: 300 } }); | ||
fireEvent.click(getByTestId("scroll-top-button")); | ||
|
||
expect(window.scrollTo).toHaveBeenCalledWith(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