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.
Browse files
Browse the repository at this point in the history
Co-authored-by: Paulo Gomes da Cruz Junior <[email protected]>
- Loading branch information
1 parent
07a93fc
commit 5f3a165
Showing
4 changed files
with
100 additions
and
22 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,27 @@ | ||
//vite test for the ComingSoonModal component | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { describe, expect, it, vi } from 'vitest'; | ||
import ComingSoonModal from '../../components/ComingSoonModal'; | ||
|
||
describe('ComingSoonModal', () => { | ||
it('renders the modal', () => { | ||
render(<ComingSoonModal openingDetails="123" setOpeningDetails={vi.fn()} />); | ||
expect(screen.getByText('Coming Soon')).toBeInTheDocument(); | ||
expect(screen.getByText('An opening details page is in development.')).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders the modal with the correct opening ID', () => { | ||
render(<ComingSoonModal openingDetails="1234" setOpeningDetails={vi.fn()} />); | ||
expect(screen.getByText('Opening ID: 1234')).toBeInTheDocument(); | ||
}); | ||
|
||
it('calls the setOpeningDetails function when the modal is closed', async() => { | ||
const setOpeningDetails = vi.fn(); | ||
render(<ComingSoonModal openingDetails="123" setOpeningDetails={setOpeningDetails} />); | ||
const closeButton = screen.getByRole('button', { name: 'Close' }); | ||
await closeButton.click(); | ||
expect(setOpeningDetails).toHaveBeenCalled(); | ||
}); | ||
|
||
}); |
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,26 @@ | ||
import { Modal } from "@carbon/react"; | ||
interface IComingSoonModal { | ||
openingDetails: string; | ||
setOpeningDetails: (openingDetails: string) => void; | ||
} | ||
|
||
const ComingSoonModal: React.FC<IComingSoonModal> = ({ | ||
openingDetails, | ||
setOpeningDetails, | ||
}) => { | ||
return ( | ||
<Modal | ||
open={openingDetails.length > 0} | ||
onRequestClose={() => setOpeningDetails("")} | ||
passiveModal | ||
modalHeading="Coming Soon" | ||
modalLabel={`Opening ID: ${openingDetails}`} | ||
> | ||
<p className="modal-subtext">An opening details page is in development.</p> <br/> | ||
<p className="modal-subtext"> | ||
{` Until it's available, search for ${openingDetails} in RESULTS to view the opening details.`} | ||
</p> | ||
</Modal> | ||
); | ||
}; | ||
export default ComingSoonModal; |
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,7 @@ | ||
@use '@bcgov-nr/nr-theme/design-tokens/variables.scss' as vars; | ||
@use '@carbon/type'; | ||
|
||
.modal-subtext { | ||
@include type.type-style('body-02'); | ||
font-size: 14px; | ||
} |
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