-
Notifications
You must be signed in to change notification settings - Fork 35
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 #13690 from transcom/MAIN-B-19044
MAIN B-19044
- Loading branch information
Showing
17 changed files
with
237 additions
and
104 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
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 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
61 changes: 61 additions & 0 deletions
61
.../ReviewSITExtensionModal/ConfirmCustomerExpenseModal/ConfirmCustomerExpenseModal.test.jsx
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,61 @@ | ||
import React from 'react'; | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
|
||
import '@testing-library/jest-dom/extend-expect'; | ||
import ConfirmCustomerExpenseModal from './ConfirmCustomerExpenseModal'; | ||
|
||
describe('ConfirmCustomerExpenseModal', () => { | ||
let setShowConfirmModal; | ||
let setValues; | ||
let values; | ||
|
||
beforeEach(() => { | ||
setShowConfirmModal = jest.fn(); | ||
setValues = jest.fn(); | ||
values = { convertToCustomerExpense: false }; | ||
}); | ||
|
||
it('renders the modal with correct content', () => { | ||
render( | ||
<ConfirmCustomerExpenseModal setShowConfirmModal={setShowConfirmModal} values={values} setValues={setValues} />, | ||
); | ||
|
||
expect(screen.getByText('Convert to Customer Expense')).toBeInTheDocument(); | ||
expect(screen.getByText('Are you sure that you would like to convert to Customer Expense?')).toBeInTheDocument(); | ||
// Check if both "Yes" and "No" buttons are rendered | ||
expect(screen.getByTestId('convertToCustomerExpenseConfirmationYes')).toBeInTheDocument(); | ||
expect(screen.getByTestId('convertToCustomerExpenseConfirmationNo')).toBeInTheDocument(); | ||
}); | ||
|
||
it('handles "Yes" button click by setting convertToCustomerExpense to true and closing the modal', () => { | ||
render( | ||
<ConfirmCustomerExpenseModal setShowConfirmModal={setShowConfirmModal} values={values} setValues={setValues} />, | ||
); | ||
|
||
const yesButton = screen.getByTestId('convertToCustomerExpenseConfirmationYes'); | ||
fireEvent.click(yesButton); | ||
expect(setValues).toHaveBeenCalledWith({ ...values, convertToCustomerExpense: true }); | ||
expect(setShowConfirmModal).toHaveBeenCalledWith(false); | ||
}); | ||
|
||
it('handles "No" button click by setting convertToCustomerExpense to false and closing the modal', () => { | ||
render( | ||
<ConfirmCustomerExpenseModal setShowConfirmModal={setShowConfirmModal} values={values} setValues={setValues} />, | ||
); | ||
|
||
const noButton = screen.getByTestId('convertToCustomerExpenseConfirmationNo'); | ||
fireEvent.click(noButton); | ||
expect(setValues).toHaveBeenCalledWith({ ...values, convertToCustomerExpense: false }); | ||
expect(setShowConfirmModal).toHaveBeenCalledWith(false); | ||
}); | ||
|
||
it('handles closing the modal via the close button', () => { | ||
render( | ||
<ConfirmCustomerExpenseModal setShowConfirmModal={setShowConfirmModal} values={values} setValues={setValues} />, | ||
); | ||
|
||
const closeButton = screen.getByRole('button', { name: /close/i }); | ||
fireEvent.click(closeButton); | ||
expect(setShowConfirmModal).toHaveBeenCalledWith(false); | ||
}); | ||
}); |
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 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
Oops, something went wrong.