generated from bcgov/quickstart-openshift
-
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
c6cb9ca
commit e7d29b4
Showing
1 changed file
with
50 additions
and
0 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,50 @@ | ||
// src/__test__/components/SilvicultureSearch/Openings/OpeningsSearchBar.test.tsx | ||
|
||
import React from "react"; | ||
import { render, screen } from "@testing-library/react"; | ||
import "@testing-library/jest-dom"; | ||
import { vi } from "vitest"; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import OpeningsTab from "../../../src/components/OpeningsTab"; | ||
import { Provider } from "react-redux"; | ||
import store from "../../store"; | ||
|
||
describe("OpeningsTab", () => { | ||
// Create a new QueryClient instance for each test | ||
const queryClient = new QueryClient(); | ||
const showSpatial = false | ||
const setShowSpatial = vi.fn() | ||
|
||
it("renders the component successfully", () => { | ||
render( | ||
<QueryClientProvider client={queryClient}> | ||
<Provider store={store}> | ||
<OpeningsTab | ||
showSpatial={showSpatial} | ||
setShowSpatial={setShowSpatial} | ||
/> | ||
</Provider> | ||
</QueryClientProvider> | ||
); | ||
// Check if the component is present with the correct text | ||
const searchInput = screen.getByText(/Track the history of openings you have looked at and check spatial information by selecting the openings in the table below/i); | ||
expect(searchInput).toBeInTheDocument(); | ||
}); | ||
|
||
it("shows the spatial area with Hide Spatial Button", () => { | ||
render( | ||
<QueryClientProvider client={queryClient}> | ||
<Provider store={store}> | ||
<OpeningsTab | ||
showSpatial={true} | ||
setShowSpatial={setShowSpatial} | ||
/> | ||
</Provider> | ||
</QueryClientProvider> | ||
); | ||
console.log(screen.debug()) | ||
// Check if the component is present with the correct text | ||
const searchInput = screen.getByRole('button', { name: /Hide Spatial/i }); | ||
expect(searchInput).toBeInTheDocument(); | ||
}); | ||
}); |