NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

import React from 'react';
import { mount } from 'enzyme';
import { MemoryRouter } from 'react-router-dom';
import { Provider } from 'react-redux';
import { Blotter, Spinner, Button, Tabs } from 'foundation-components-core';
import {
mockChangedData,
path,
batchRefSelected,
sortColumn,
fetchMoreResult,
previousResult,
previousWithFetchMoreResult,
previousWithoutFetchMoreResult,
selectedRowsWithCommonActions,
mockClient,
multipleSelectedRows,
singleSelectedRow,
clientQuery,
routeAfterBatchRefSelected,
store,
mockRows,
mockFilter,
mockCols,
mockPrintExportVariables,
mockUpdatedDataWithFetchMore,
mockSearchFilterVariable
} from './mockData';
import { MandateBatchList } from '../MandateBatchList';
import '../../../../../../i18n';
import { getRows, getColumns, getFilters } from '../MandateBatchListBuilder';

jest.mock('../MandateBatchListBuilder');

const utils = require('../MandateBatchListBuilder');

utils.getRows = jest.fn().mockImplementation(() => mockRows);

utils.getColumns = jest.fn().mockImplementation(() => mockCols);

utils.getFilters = jest.fn().mockImplementation(() => mockFilter);

utils.setUpdatedData = jest
.fn()
.mockImplementation(() => mockUpdatedDataWithFetchMore);

utils.setFetchMoreVariables = jest
.fn()
.mockImplementation(() => mockSearchFilterVariable);

utils.setPrintExportVariables = jest
.fn()
.mockImplementation(() => mockPrintExportVariables);

const selectingTab = (mandateBatchPage, primaryTab, secondaryTab) => {
mandateBatchPage
.find(MandateBatchList)
.find(Blotter)
.find(Tabs)
.at(primaryTab)
.find(Button)
.at(secondaryTab)
.simulate('click');
};

const mountComponent = () => {
const MandateBatchListPage = mount(
<Provider store={store}>
<MemoryRouter>
<MandateBatchList
data={mockChangedData}
client={mockClient}
location={path}
/>
</MemoryRouter>
</Provider>
);
MandateBatchListPage.find(MandateBatchList)
.instance()
.componentWillReceiveProps({ data: mockChangedData });
return MandateBatchListPage;
};

describe('Mandate Batch', () => {
describe('Mandate Batch List with no props passed', () => {
it('checks spinner is rendered', () => {
const MandateBatchListPage = mount(
<Provider store={store}>
<MemoryRouter>
<MandateBatchList data={{}} client={mockClient} location={path} />
</MemoryRouter>
</Provider>
);
expect(MandateBatchListPage.find(Spinner).length).toBe(1);
});
});

describe('Mandate Batch List with props passed', () => {
it('checks blotter is rendered', () => {
const MandateBatchListPage = mountComponent();

expect(MandateBatchListPage.find(Blotter).length).toBe(1);
});

describe('Onclicking Sort Column', () => {
it('checks onSort calls fetchmore', () => {
const mandateTransactionListPage = mountComponent();
mandateTransactionListPage
.find(MandateBatchList)
.find(Blotter)
.props()
.onSort(sortColumn, 'DESC');
expect(mockChangedData.fetchMore).toHaveBeenCalled();
});

it('checks onUpdateQuery return correct data when fetchMoreResult is not null', () => {
const mandateTransactionListPage = mountComponent();
const onSortData = mandateTransactionListPage
.find(MandateBatchList)
.instance()
.onUpdateQuery(previousResult, { fetchMoreResult });
expect(onSortData).toEqual(previousWithFetchMoreResult);
});

it('checks onUpdateQuery return correct data when fetchMoreResult is null', () => {
const mandateTransactionListPage = mountComponent();
const onSortData = mandateTransactionListPage
.find(MandateBatchList)
.instance()
.onUpdateQuery(previousResult, { fetchMoreResult: null });
expect(onSortData.getMandateBatchList.mandateHeaderDtls).toEqual(
previousResult.getMandateBatchList.mandateHeaderDtls
);
});
});

describe('On clicking ShowMore', () => {
it('checks onLoadMore calls fetchMore ', () => {
const mandateTransactionListPage = mountComponent();
mandateTransactionListPage
.find(MandateBatchList)
.find(Blotter)
.props()
.onLoadMore();
expect(mockChangedData.fetchMore).toHaveBeenCalled();
});

it('checks onLoadMoreUpdateQuery return correct data with fetchMoreResult not null', () => {
const mandateTransactionListPage = mountComponent();
const onLoadMoreData = mandateTransactionListPage
.find(MandateBatchList)
.instance()
.onLoadMoreUpdateQuery(previousResult, { fetchMoreResult });
expect(onLoadMoreData).toEqual(previousWithFetchMoreResult);
});

it('checks onLoadMoreUpdateQuery return correct data with fetchMoreResult not null', () => {
const mandateTransactionListPage = mountComponent();
const onLoadMoreData = mandateTransactionListPage
.find(MandateBatchList)
.instance()
.onLoadMoreUpdateQuery(previousResult, { fetchMoreResult: null });
expect(onLoadMoreData.getMandateBatchList).toEqual(
previousWithoutFetchMoreResult
);
});
});

describe('On removing Filter', () => {
it('checks submitFilter is called with correct updateFilter when search filter is removed', () => {
const mandateTransactionListPage = mountComponent();
mandateTransactionListPage
.find(MandateBatchList)
.find(Blotter)
.props()
.onFilterRemove('BANK_REF');
expect(mockChangedData.fetchMore).toBeCalledWith(
expect.objectContaining({
variables: mockSearchFilterVariable
})
);
});

it('checks submitFilter is called with correct updateFilter when daterange filter is removed', () => {
const mandateTransactionListPage = mountComponent();
mandateTransactionListPage
.find(MandateBatchList)
.find(Blotter)
.props()
.onFilterRemove('START_DATE');
expect(mockChangedData.fetchMore).toBeCalledWith(
expect.objectContaining({
variables: mockSearchFilterVariable
})
);
});

it('checks submitFilter is called with correct updateFilter when range filter is removed', () => {
const mandateTransactionListPage = mountComponent();
mandateTransactionListPage
.find(MandateBatchList)
.find(Blotter)
.props()
.onFilterRemove('MANDATE_AMOUNT');
expect(mockChangedData.fetchMore).toBeCalledWith(
expect.objectContaining({
variables: mockSearchFilterVariable
})
);
});

it('checks onRemoveFilter calls fetchMore ', () => {
const mandateTransactionListPage = mountComponent();
mandateTransactionListPage
.find(MandateBatchList)
.find(Blotter)
.props()
.onFilterRemove();
expect(mockChangedData.fetchMore).toHaveBeenCalled();
});
});

describe('On clicking PrimaryTab', () => {
it('checks page should be routed to mandate route', () => {
const mandateTransactionPage = mountComponent();
mandateTransactionPage
.find(MandateBatchList)
.instance()
.onPrimaryTabSelect('dda');
expect(
mandateTransactionPage.find(MandateBatchList).instance().state
.redirectPath
).toBe('collections/lists/managelists/mandate/batches');
});

it('checks page should be routed to default route', () => {
const mandateTransactionPage = mountComponent();
mandateTransactionPage
.find(MandateBatchList)
.instance()
.onPrimaryTabSelect('wrongValue');
expect(
mandateTransactionPage.find(MandateBatchList).instance().state
.redirectPath
).toBe('');
});

it('checks page should be routed to direct debits route', () => {
const mandateTransactionPage = mountComponent();
selectingTab(mandateTransactionPage, 0, 0);
expect(
mandateTransactionPage.find(MandateBatchList).instance().state
.redirectPath
).toBe('collections/lists/managelists/ddi/batches');
});

it('checks page should be routed to files route', () => {
const mandateTransactionPage = mountComponent();
selectingTab(mandateTransactionPage, 0, 2);
expect(
mandateTransactionPage.find(MandateBatchList).instance().state
.redirectPath
).toBe('collections/lists/managelists/files');
});
});

describe('On clicking SecondaryTab', () => {
it('checks page should be routed to correct route', () => {
const mandateTransactionPage = mountComponent();
selectingTab(mandateTransactionPage, 1, 0);
expect(
mandateTransactionPage.find(MandateBatchList).instance().state
.redirectPath
).toBe('');
selectingTab(mandateTransactionPage, 1, 1);
expect(
mandateTransactionPage.find(MandateBatchList).instance().state
.redirectPath
).toBe('collections/lists/managelists/mandate/transactions');
});
});

describe('On clicking first column link of each row', () => {
it('checks onCellClick is called', () => {
const mandateTransactionPage = mountComponent();
mandateTransactionPage
.find(MandateBatchList)
.find(Blotter)
.props()
.onCellClick(batchRefSelected);
expect();
expect(
mandateTransactionPage.find(MandateBatchList).instance().state
.redirectPath
).toBe(routeAfterBatchRefSelected);
});
});

describe('On clicking row checkbox', () => {
it('checks getCommonactions is called', () => {
const mandateTransactionPage = mountComponent();
mandateTransactionPage
.find(MandateBatchList)
.find(Blotter)
.props()
.onRowCheckboxClick(selectedRowsWithCommonActions);
expect(utils.getCommonActions).toHaveBeenCalled();
});
});

describe('On selecting Subactions', () => {
it('checks routeToSummaryPage is called with correct data on click of view', () => {
const mandateTransactionPage = mountComponent();
mandateTransactionPage
.find(MandateBatchList)
.instance().routeToSummaryPage = jest.fn();
mandateTransactionPage
.find(MandateBatchList)
.find(Blotter)
.props()
.actions.VIEW.action(singleSelectedRow);
expect(
mandateTransactionPage.find(MandateBatchList).instance()
.routeToSummaryPage
).toBeCalledWith('MANDATE001');
});

it('checks routeToInitiatePage is called with correct data on click of edit', () => {
const mandateTransactionPage = mountComponent();
mandateTransactionPage
.find(MandateBatchList)
.instance().routeToInitiatePage = jest.fn();
mandateTransactionPage
.find(MandateBatchList)
.find(Blotter)
.props()
.actions.EDIT.action(singleSelectedRow);
expect(
mandateTransactionPage.find(MandateBatchList).instance()
.routeToInitiatePage
).toBeCalledWith([{ id: 'MANDATE001' }]);
});

it('checks routeToInitiatePage resets state with correct data', () => {
const mandateTransactionPage = mountComponent();
mandateTransactionPage
.find(MandateBatchList)
.instance()
.routeToInitiatePage([{ id: 'MANDATE001' }]);
expect(
mandateTransactionPage.find(MandateBatchList).instance().state
.redirectPath
).toBe('collections/directdebit/initiate');
expect(
mandateTransactionPage.find(MandateBatchList).instance().state
.redirect
).toBe(true);
expect(
mandateTransactionPage.find(MandateBatchList).instance().state
.redirectParam
).toEqual({ batchRefNo: 'MANDATE001' });
});

it('checks client query is called with correct data on click of export', () => {
const mandateTransactionPage = mountComponent();
mandateTransactionPage
.find(MandateBatchList)
.find(MandateBatchList)
.instance().setPrintExportVariables = jest.fn();

mandateTransactionPage
.find(MandateBatchList)
.find(Blotter)
.props()
.actions.EXPORT.action(multipleSelectedRows);
expect(
mandateTransactionPage.find(MandateBatchList).props().client.query
).toBeCalledWith(
expect.objectContaining({
variables: clientQuery
})
);
expect(
mandateTransactionPage.find(MandateBatchList).instance()
.setPrintExportVariables
);
expect(
mandateTransactionPage.find(MandateBatchList).props().client.query
).toBeCalledWith(
expect.objectContaining({
variables: clientQuery
})
);
});

it('checks client query is called with correct data on click of print', () => {
const mandateTransactionPage = mountComponent();
mandateTransactionPage
.find(MandateBatchList)
.instance().setPrintExportVariables = jest.fn();

mandateTransactionPage
.find(MandateBatchList)
.find(Blotter)
.props()
.actions.PRINT.action(multipleSelectedRows);
expect(
mandateTransactionPage.find(MandateBatchList).props().client.query
).toBeCalledWith(
expect.objectContaining({
variables: clientQuery
})
);
expect(
mandateTransactionPage.find(MandateBatchList).instance()
.setPrintExportVariables
);
expect(
mandateTransactionPage.find(MandateBatchList).props().client.query
).toBeCalledWith(
expect.objectContaining({
variables: clientQuery
})
);
});
});
});
});
     
 
what is notes.io
 

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

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.