-
Notifications
You must be signed in to change notification settings - Fork 2
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
a77cf71
commit 3b005ae
Showing
9 changed files
with
1,364 additions
and
746 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// __tests__/LandingPage.test.tsx | ||
import { render, screen } from "testUtils"; | ||
|
||
import { MockAuthentication } from "firebase-mock"; | ||
import MyBookingsPage from "@/components/src/client/routes/myBookings/myBookingsPage"; | ||
import { useRouter } from "next/navigation"; | ||
|
||
jest.mock("next/navigation", () => ({ | ||
useRouter: jest.fn(), | ||
})); | ||
|
||
jest.mock("../lib/firebase/firebaseClient.ts", () => ({ | ||
auth: new MockAuthentication(), | ||
})); | ||
|
||
jest.mock( | ||
"../components/src/client/routes/components/AuthProvider.tsx", | ||
() => ({ | ||
useAuth: { | ||
user: { | ||
email: "abc12345", | ||
}, | ||
loading: false, | ||
error: null, | ||
}, | ||
}) | ||
); | ||
|
||
describe("Form Navigation", () => { | ||
it('My Bookings page "book more" button goes to form landing page', () => { | ||
// Mock the `push` function | ||
const push = jest.fn(); | ||
(useRouter as jest.Mock).mockReturnValue({ | ||
push, | ||
}); | ||
|
||
render(MyBookingsPage()); | ||
|
||
const button = screen.getByTestId("book-btn"); | ||
button.click(); | ||
|
||
expect(push).toHaveBeenCalledWith("/book"); | ||
}); | ||
}); |
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
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,19 @@ | ||
import type { Config } from "jest"; | ||
import nextJest from "next/jest.js"; | ||
|
||
const createJestConfig = nextJest({ | ||
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment | ||
dir: "./", | ||
}); | ||
|
||
// Add any custom config to be passed to Jest | ||
const config: Config = { | ||
coverageProvider: "v8", | ||
preset: "ts-jest", | ||
testEnvironment: "jsdom", | ||
// Add more setup options before each test is run | ||
// setupFiles: ["./jest.setup.ts"], | ||
}; | ||
|
||
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async | ||
export default createJestConfig(config); |
Oops, something went wrong.