Notes
![]() ![]() Notes - notes.io |
const fetchPartnerFeedsAuditMock = jest.fn();
const fetchPartnerFeedsMarketingContextMock = jest.fn();
const updateValueMock = jest.fn();
partnerFeedsAudit.fetchPartnerFeedsAudit = fetchPartnerFeedsAuditMock;
partnerFeedsAudit.fetchPartnerFeedsMarketingContext = fetchPartnerFeedsMarketingContextMock;
partnerFeedsAudit.updateValue = updateValueMock;
render(
<Provider {...{partnerFeedsAudit, appState}}>
<Router>
<FeedDetailsPage partnerDetails={{partner: 'TestPartner', feedId: '123', feedTypes: ['Type1']}} />
</Router>
</Provider>
);
expect(fetchPartnerFeedsAuditMock).toHaveBeenCalledWith('TestPartner', expect.any(String));
expect(fetchPartnerFeedsMarketingContextMock).toHaveBeenCalledWith('TestPartner', '123', 'Type1');
expect(updateValueMock).toHaveBeenCalled();
});
it('handles date option click and triggers data refresh', async () => {
const updateValueMock = jest.fn();
const fetchPartnerFeedsAuditMock = jest.fn();
partnerFeedsAudit.updateValue = updateValueMock;
partnerFeedsAudit.fetchPartnerFeedsAudit = fetchPartnerFeedsAuditMock;
const {getByText} = render(
<Provider {...{partnerFeedsAudit, appState}}>
<Router>
<FeedDetailsPage />
</Router>
</Provider>
);
// Simulate clicking the ActionsMenu to select a new date
const last7Days = getByText('Last 7 days');
fireEvent.click(last7Days);
expect(updateValueMock).toHaveBeenCalledWith({key: 'explorerDateFeed', value: 'Last 7 days'});
expect(fetchPartnerFeedsAuditMock).toHaveBeenCalledWith(expect.anything(), expect.anything());
});
it('navigates slider and updates selected feed', async () => {
const updateValueMock = jest.fn();
partnerFeedsAudit.updateValue = updateValueMock;
const {getByText} = render(
<Provider {...{partnerFeedsAudit, appState}}>
<Router>
<FeedDetailsPage />
</Router>
</Provider>
);
// Assuming "Next" button in Slider to trigger index change
const nextButton = getByText('Next');
fireEvent.click(nextButton);
expect(updateValueMock).toHaveBeenCalledWith({key: 'selectedIndex', value: expect.any(Number)});
});
it('triggers download when download icon is clicked', async () => {
const downloadMCMock = jest.fn();
partnerFeedsAudit.downloadMC = downloadMCMock;
partnerFeedsAudit.marketingContextAudit = { partnerMarketingContextFileDetails: [{ key: 'Context1', fileSize: '100', geo: 'US', channel: 'Online', fileName: 'file1', lang: 'en', segment: 'consumer' }] };
const {getByTitle} = render(
<Provider {...{partnerFeedsAudit, appState}}>
<Router>
<FeedDetailsPage />
</Router>
</Provider>
);
const downloadButton = getByTitle('Download');
fireEvent.click(downloadButton);
expect(downloadMCMock).toHaveBeenCalledWith(expect.anything(), expect.anything(), expect.anything(), expect.anything(), expect.anything(), expect.anything(), expect.anything(), expect.anything());
});
it('displays loader when data is being fetched', () => {
partnerFeedsAudit.isFetchingPartnerFeedDetails = true;
const {getByTestId} = render(
<Provider {...{partnerFeedsAudit, appState}}>
<Router>
<FeedDetailsPage />
</Router>
</Provider>
);
const loader = getByTestId('loader');
expect(loader).toBeInTheDocument();
});
it('updates feed type via TypeAhead and fetches marketing context', async () => {
const updateValueMock = jest.fn();
const fetchPartnerFeedsMarketingContextMock = jest.fn();
partnerFeedsAudit.updateValue = updateValueMock;
partnerFeedsAudit.fetchPartnerFeedsMarketingContext = fetchPartnerFeedsMarketingContextMock;
const {getByText, findByText} = render(
<Provider {...{partnerFeedsAudit, appState}}>
<Router>
<FeedDetailsPage />
</Router>
</Provider>
);
// Simulate opening TypeAhead and selecting an option
const typeAhead = getByText('Feed Type'); // Adjust text if needed
fireEvent.click(typeAhead);
const option = await findByText('Type2'); // This should be the actual option text displayed
fireEvent.click(option);
expect(updateValueMock).toHaveBeenCalledWith({key: 'selectedFeedType', value: expect.any(Object)});
expect(fetchPartnerFeedsMarketingContextMock).toHaveBeenCalledWith(expect.anything(), expect.anything(), 'Type2');
});
it('navigates back to the partner feeds audit page on back link click', () => {
const historyMock = { push: jest.fn() };
const {getByText} = render(
<Provider {...{partnerFeedsAudit, appState}}>
<Router>
<FeedDetailsPage history={historyMock} />
</Router>
</Provider>
);
const backButton = getByText('Back to Partner Feeds Audit');
fireEvent.click(backButton);
expect(historyMock.push).toHaveBeenCalledWith({
pathname: '/partner-audit'
});
});
it('handles timeline index click and updates the feed', () => {
const updateValueMock = jest.fn();
partnerFeedsAudit.updateValue = updateValueMock;
const {getByText} = render(
<Provider {...{partnerFeedsAudit, appState}}>
<Router>
<FeedDetailsPage />
</Router>
</Provider>
);
// Assume "Index 1" is the text associated with the second index
const indexLink = getByText('Index 1');
fireEvent.click(indexLink);
expect(updateValueMock).toHaveBeenCalledWith({key: 'selectedIndex', value: 1});
expect(updateValueMock).toHaveBeenCalledWith({key: 'selectedFeedId', value: expect.any(Object)});
});
![]() |
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