Notes
![]() ![]() Notes - notes.io |
import { useDispatch } from 'react-redux';
import { onToggleShowMyData, filterArrayForActiveCloseSubmission } from './YourComponent'; // Update the path accordingly
jest.mock('react-redux', () => ({
useDispatch: jest.fn(),
}));
describe('onToggleShowMyData', () => {
let dispatch;
beforeEach(() => {
dispatch = jest.fn();
useDispatch.mockReturnValue(dispatch);
localStorage.clear();
});
test('should filter data correctly when checked is true and user matches underwriter or assistant_underwriter', () => {
localStorage.setItem('email', '[email protected]');
const data = [
{ underwriter: '[email protected]', assistant_underwriter: '', business_status: 'In Progress' },
{ underwriter: '[email protected]', assistant_underwriter: '[email protected]', business_status: 'Review Complete' },
];
const checked = true;
onToggleShowMyData(data, checked);
expect(dispatch).toHaveBeenCalledWith(expect.any(Function));
// Assuming `setSearchFilterData` is an action creator and you can assert its call
// You might need to mock it separately if it's not automatically mocked
});
test('should not filter data when checked is false', () => {
localStorage.setItem('email', '[email protected]');
const data = [
{ underwriter: '[email protected]', assistant_underwriter: '', business_status: 'In Progress' },
{ underwriter: '[email protected]', assistant_underwriter: '', business_status: 'Review Complete' },
];
const checked = false;
onToggleShowMyData(data, checked);
expect(dispatch).toHaveBeenCalledWith(expect.any(Function));
// Again, ensure you have the correct assertions here
});
});
describe('filterArrayForActiveCloseSubmission', () => {
let dispatch;
beforeEach(() => {
dispatch = jest.fn();
useDispatch.mockReturnValue(dispatch);
});
test('should filter active and close submissions correctly', () => {
const data = [
{ business_status: 'Review Complete' },
{ business_status: 'In Progress' },
];
const showActiveSubmission = true;
const showReviewedSubmission = false;
const showAllSubmissions = false;
filterArrayForActiveCloseSubmission(data, showActiveSubmission, showReviewedSubmission, showAllSubmissions);
expect(dispatch).toHaveBeenCalledWith(expect.any(Function));
// Mock and assert actions as necessary
});
test('should handle no data scenario', () => {
const data = [];
const showActiveSubmission = false;
const showReviewedSubmission = false;
const showAllSubmissions = true;
filterArrayForActiveCloseSubmission(data, showActiveSubmission, showReviewedSubmission, showAllSubmissions);
expect(dispatch).toHaveBeenCalledWith(expect.any(Function));
// Mock and assert actions as necessary
});
});
expect(dispatch).toHaveBeenCalledWith(setSearchFilterData(filteredData));
expect(getFilteredArray).toHaveBeenCalledWith(filteredData, pageArray, pageSize, 1);
expect(setPagination).toHaveBeenCalledWith(filteredData);
expect(dispatch).toHaveBeenCalledWith(setSearchFilterData(searchFilterdData));
expect(getFilteredArray).toHaveBeenCalledWith(searchFilterdData, pageArray, pageSize, 1);
expect(setPagination).toHaveBeenCalledWith(searchFilterdData);
expect(dispatch).toHaveBeenCalledWith(setSearchFilterData(activeFilteredData));
expect(dispatch).toHaveBeenCalledWith(setSearchFilterData(searchFilterdData));
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team