-
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.
Merge pull request #36 from atlp-rwanda/ft-delete-product
Enable to delete a product
- Loading branch information
Showing
13 changed files
with
427 additions
and
83 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
37 changes: 37 additions & 0 deletions
37
src/__test__/pages/Products/DashboardDeleteProduct.test.tsx
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,37 @@ | ||
import React from 'react'; | ||
import { screen, fireEvent } from '@testing-library/react'; | ||
import { describe, it } from 'vitest'; // Assuming 'vitest' is your testing framework | ||
import DeleteCouponModal from '../../../components/Products/DashboardDeleteProduct/DashboardDeleteProduct'; // Adjust the import path as per your project structure | ||
import { render } from '../../utils/test-utils'; // Adjust the path as per your project structure | ||
import { Provider } from 'react-redux'; | ||
import { MemoryRouter } from 'react-router-dom'; | ||
import mockStore from '../../utils/mockStore'; // Adjust the path as per your project structure | ||
|
||
describe('DeleteCouponModal', () => { | ||
it('renders correctly with modal content', async () => { | ||
render( | ||
<Provider store={mockStore}> | ||
<MemoryRouter> | ||
<DeleteCouponModal /> | ||
</MemoryRouter> | ||
</Provider> | ||
); | ||
|
||
expect(screen.getByText('Delete coupon FLAT10!')).toBeInTheDocument(); | ||
expect(screen.getByText('Are you sure you want to accept this?')).toBeInTheDocument(); | ||
expect(screen.getByText('No, Cancel')).toBeInTheDocument(); | ||
expect(screen.getByText('Yes, Deactivate')).toBeInTheDocument(); | ||
}); | ||
|
||
it('triggers cancel action when "No, Cancel" button is clicked', async () => { | ||
render( | ||
<Provider store={mockStore}> | ||
<MemoryRouter> | ||
<DeleteCouponModal /> | ||
</MemoryRouter> | ||
</Provider> | ||
); | ||
|
||
fireEvent.click(screen.getByText('No, Cancel')); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
src/components/Products/DashboardDeleteProduct/DashboardDeleteProduct.tsx
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,18 @@ | ||
import React from 'react'; | ||
|
||
const DeleteCouponModal: React.FC = () => { | ||
return ( | ||
<div className="bg-white p-4 rounded-lg shadow-md"> | ||
<h1 className="text-red-500 font-bold">Delete coupon FLAT10!</h1> | ||
<p>Are you sure you want to accept this?</p> | ||
<div className="flex justify-between mt-4"> | ||
<button className="bg-white border border-gray-300 text-black py-2 px-4 rounded hover:bg-gray-100"> | ||
No, Cancel | ||
</button> | ||
<button className="bg-red-500 text-white py-2 px-4 rounded hover:bg-red-600">Yes, Deactivate</button> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DeleteCouponModal; |
Oops, something went wrong.