-
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
1 parent
ccf46da
commit 62cdb9e
Showing
34 changed files
with
1,460 additions
and
1,095 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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 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,38 @@ | ||
import { render } from "@testing-library/react"; | ||
import { userEvent } from "@testing-library/user-event"; | ||
import "@testing-library/jest-dom"; | ||
import { test, expect } from "vitest"; | ||
import axe from "axe-core"; | ||
import { Provider } from "react-redux"; | ||
import store from "../redux/store.ts"; | ||
import { createMemoryRouter, RouterProvider } from "react-router-dom"; | ||
import { routes } from "../routes/routes.tsx"; | ||
|
||
test("Testing Health Screen", async () => { | ||
const user = userEvent.setup(); | ||
const router = createMemoryRouter(routes, { | ||
initialEntries: ["/health"], | ||
initialIndex: 1, | ||
}); | ||
|
||
const { container, getByText, getByRole } = render( | ||
<Provider store={store}> | ||
<RouterProvider router={router} /> | ||
</Provider> | ||
); | ||
expect(getByText("Test Flash Messages")).toBeInTheDocument(); | ||
|
||
const results = await axe.run(container, { | ||
rules: { "color-contrast": { enabled: false } }, | ||
}); | ||
expect(results.incomplete.length).toBe(0); | ||
expect(results.violations.length).toBe(0); | ||
|
||
const div = document.querySelector(".message-success"); | ||
expect(div).not.toBeInTheDocument(); | ||
|
||
await user.click(getByRole("button", { name: "Test Flash Messages" })); | ||
expect( | ||
getByText("This is a test of a successful message. Congrats!") | ||
).toBeInTheDocument(); | ||
}); |
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,52 @@ | ||
import { setupServer } from "msw/node"; | ||
import { render, waitFor } from "@testing-library/react"; | ||
import "@testing-library/jest-dom"; | ||
import { beforeAll, afterAll, afterEach, test, expect } from "vitest"; | ||
import axe from "axe-core"; | ||
import { Provider } from "react-redux"; | ||
import store from "../redux/store.ts"; | ||
|
||
import HomeScreen from "./HomeScreen.tsx"; | ||
import { BrowserRouter } from "react-router-dom"; | ||
import { handlers } from "../../tests/handlers.ts"; | ||
|
||
const server = setupServer(...handlers); | ||
|
||
beforeAll(() => server.listen()); | ||
afterEach(() => server.resetHandlers()); | ||
afterAll(() => server.close()); | ||
|
||
const HomeScreenComponent = ( | ||
<Provider store={store}> | ||
<HomeScreen /> | ||
</Provider> | ||
); | ||
|
||
test("Test Home Page Loaded Content", async () => { | ||
const { container, findByText } = render(HomeScreenComponent, { | ||
wrapper: BrowserRouter, | ||
}); | ||
let loader = document.querySelector(".home-page-loading-container"); | ||
expect(loader).toBeInTheDocument(); | ||
|
||
await waitFor(async () => { | ||
const results = await axe.run(container, { | ||
rules: { "color-contrast": { enabled: false } }, | ||
}); | ||
expect(results.incomplete.length).toBe(0); | ||
expect(results.violations.length).toBe(0); | ||
}); | ||
|
||
loader = document.querySelector(".home-page-loading-container"); | ||
expect(loader).not.toBeInTheDocument(); | ||
|
||
expect( | ||
await findByText("How LEDs Work - Unravel the Mysteries of How LEDs Work!") | ||
).toBeInTheDocument(); | ||
expect( | ||
await findByText( | ||
"Single Phase Electricity Explained - wiring diagram energy meter" | ||
) | ||
).toBeInTheDocument(); | ||
expect(await findByText("Halo Full OST")).toBeInTheDocument(); | ||
}); |
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,70 @@ | ||
import { setupServer } from "msw/node"; | ||
import { render, screen, act, waitFor } from "@testing-library/react"; | ||
import "@testing-library/jest-dom"; | ||
import { beforeAll, afterAll, afterEach, test, expect, vitest } from "vitest"; | ||
import axe from "axe-core"; | ||
import { Provider } from "react-redux"; | ||
import store from "../redux/store.ts"; | ||
import SearchScreen from "./SearchScreen.tsx"; | ||
import { BrowserRouter } from "react-router-dom"; | ||
import { handlers } from "../../tests/handlers.ts"; | ||
import { useState } from "react"; | ||
|
||
const server = setupServer(...handlers); | ||
|
||
beforeAll(() => { | ||
server.listen({ onUnhandledRequest: "error" }); | ||
const mockIntersectionObserver = vitest.fn(); | ||
mockIntersectionObserver.mockReturnValue({ | ||
observe: () => null, | ||
unobserve: () => null, | ||
disconnect: () => null, | ||
}); | ||
window.IntersectionObserver = mockIntersectionObserver; | ||
|
||
vitest.mock("react-router-dom", async () => { | ||
const props = await vitest.importActual("react-router-dom"); | ||
return { | ||
...props, | ||
useSearchParams: () => { | ||
let mockParams = "q=java"; | ||
const [params, setParams] = useState(new URLSearchParams(mockParams)); | ||
return [ | ||
params, | ||
(newParams: string) => { | ||
mockParams = newParams; | ||
setParams(new URLSearchParams(newParams)); | ||
}, | ||
]; | ||
}, | ||
}; | ||
}); | ||
}); | ||
afterEach(() => server.resetHandlers()); | ||
afterAll(() => server.close()); | ||
|
||
test("Test Search Page Loaded Content", async () => { | ||
const { container } = await act(async () => | ||
render( | ||
<Provider store={store}> | ||
<SearchScreen /> | ||
</Provider>, | ||
{ wrapper: BrowserRouter } | ||
) | ||
); | ||
|
||
await waitFor(async () => { | ||
const results = await axe.run(container, { | ||
rules: { "color-contrast": { enabled: false } }, | ||
}); | ||
expect(results.incomplete.length).toBe(0); | ||
expect(results.violations.length).toBe(0); | ||
}); | ||
|
||
expect(screen.getByText("Search results for 'java'")).toBeInTheDocument(); | ||
expect(screen.getByText("Java Basics - An Overview")).toBeInTheDocument(); | ||
expect( | ||
screen.getByText("Introduction to Variables in Java") | ||
).toBeInTheDocument(); | ||
expect(screen.getByText("Identifiers in Java")).toBeInTheDocument(); | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.