Notes
![]() ![]() Notes - notes.io |
import { mount, shallow } from 'enzyme';
import { Select, Switch, ActionBar, Toast } from 'foundation-components-core';
import { Import } from '../Import';
import FileTemplateSelect from '../components/FileTemplateSelect';
import ImportFileType from '../components/ImportFileType';
import ImportSwitch from '../components/ImportSwitch';
import '../../../../i18n';
const props = {
fileTypes: ['PAYMENT', 'Payee', 'Data Template', 'DirectDebit', 'Mandates'],
switchOptions: [
{
id: '0',
label: 'BULK IMPORT',
selected: true
},
{
id: '1',
label: 'IH2H'
}
]
};
const switchOptions = [
{ id: 0, label: 'BULK IMPORT', selected: true },
{ id: 1, label: 'iH2H', selected: false }
];
const fileTemplateOptions = [
{ formatId: 'IPAYMENT-CSV', formatDesc: 'IPAYMENT-CSV' }
];
const fileTypes = ['PAYMENT', 'Payees', 'DirectDebit', 'Mandates'];
const mockCallback = jest.fn();
jest.mock('../../../../services/api/index', () => ({
serviceConnector: (service, b, c, d) => {
console.log(service, 'service');
let response = {};
if (service === 'common/bulkimport/initiate/getFileTypes') {
console.log('In service');
response = {
payloadResponse: {
transactionSuccess: true,
fileTypesList: [
{
key: 'PAYMENT',
label: 'PAYMENT',
encryptFlag: false
},
{
key: 'PAYEE',
label: 'Payee',
encryptFlag: false
},
{
key: 'DATATEMPLATES',
label: 'DataTemplates',
encryptFlag: false
},
{
key: 'DDI',
label: 'Direct Debit',
encryptFlag: false
},
{
key: 'MANDATE',
label: 'Mandate',
encryptFlag: false
}
]
}
};
return new Promise((resolve) => resolve(response));
} else if (
service === 'common/bulkimport/initiate/getEntitledChannelTypes'
) {
response = {
payloadResponse: {
transactionSuccess: true,
applicableChannels: ['BULKIMPORT']
}
};
return new Promise((resolve) => resolve(response));
} else if (service === 'common/bulkimport/initiate/getBulkimportEntityId') {
response = {
payloadResponse: {
transactionSuccess: true,
entityId: '16611'
}
};
return new Promise((resolve) => resolve(response));
} else if (service === 'common/bulkimport/initiate/getFileTypeConfig') {
response = {
payloadResponse: {
transactionSuccess: true,
fileTypeConfig: [
{
maxSize: '10',
allowedTxnExtn: ['CSV'],
allowedAttchmntExtn: ['ZIP']
}
],
isValueDateAllowed: false
}
};
return new Promise((resolve) => resolve(response));
}
}
}));
const getFileTypesResponse = {
payloadResponse: {
transactionSuccess: true,
fileTypesList: [
{
key: 'PAYMENT',
label: 'PAYMENT',
isDefault: 'PAYMENT',
encryptFlag: false
},
{
key: 'PAYEE',
label: 'Payee',
isDefault: 'PAYEE',
encryptFlag: false
},
{
key: 'DATATEMPLATES',
label: 'DataTemplates',
isDefault: 'DATATEMPLATES',
encryptFlag: false
},
{
key: 'DDI',
label: 'Direct Debit',
isDefault: 'DDI',
encryptFlag: false
},
{
key: 'MANDATE',
label: 'Mandate',
isDefault: 'MANDATE',
encryptFlag: false
}
]
}
};
const getEntitlementChannelTypesResponse = {
payloadResponse: {
transactionSuccess: true,
applicableChannels: ['BULKIMPORT']
}
};
const getEntitlementChannelTypesRequest = {
fileType: 'PAYMENT'
};
const getFileFormatsResponse = {
payloadResponse: {
transactionSuccess: true,
channelFormats: {
fileFormats: [],
templateFormats: [
{
isInvoiceApplicable: false,
templateId: 'ANJULA_TEST004',
templateDesc: 'ANJULA_TEST004',
isRoutingFlow: false
},
{
isInvoiceApplicable: false,
templateId: 'NGTEMP2',
templateDesc: 'NGTEMP2',
isRoutingFlow: false
},
{
isInvoiceApplicable: false,
templateId: 'NGXCEL2',
templateDesc: 'NGXCEL2',
isRoutingFlow: false
},
{
isInvoiceApplicable: false,
templateId: '1AM_EQUITY_NEW1',
templateDesc: '1AM_EQUITY_NEW1',
isRoutingFlow: false
},
{
isInvoiceApplicable: false,
templateId: 'LBC-ACH-RTGS',
templateDesc: 'LBC-ACH-RTGS',
isRoutingFlow: false
},
{
isInvoiceApplicable: false,
templateId: 'FIXEDLEN',
templateDesc: 'FIXEDLEN',
isRoutingFlow: false
},
{
isInvoiceApplicable: false,
templateId: 'NG-TEMP1',
templateDesc: 'NG-TEMP1',
isRoutingFlow: false
},
{
isInvoiceApplicable: false,
templateId: 'KUNNAM',
templateDesc: 'KUNNAM',
isRoutingFlow: false
},
{
isInvoiceApplicable: false,
templateId: '1AM_EQUITY_NEW6',
templateDesc: '1AM_EQUITY_NEW6',
isRoutingFlow: false
},
{
isInvoiceApplicable: false,
templateId: '1AM_EQUITY_NEW7',
templateDesc: '1AM_EQUITY_NEW7',
isRoutingFlow: false
},
{
isInvoiceApplicable: false,
templateId: '1AM_EQUITY_NEW3',
templateDesc: '1AM_EQUITY_NEW3',
isRoutingFlow: false
},
{
isInvoiceApplicable: true,
templateId: '1AM_EQUITY_NEW4',
templateDesc: '1AM_EQUITY_NEW4',
isRoutingFlow: false
},
{
isInvoiceApplicable: false,
templateId: '1AM_EQUITY_NEW5',
templateDesc: '1AM_EQUITY_NEW5',
isRoutingFlow: false
},
{
isInvoiceApplicable: false,
templateId: 'UDA_Template_SG',
templateDesc: 'UDA_Template_SG',
isRoutingFlow: false
},
{
isInvoiceApplicable: false,
templateId: 'CDPAYMENT',
templateDesc: 'CDPAYMENT',
isRoutingFlow: false
}
]
}
}
};
const getFileFormatRequest = { fileType: 'PAYMENT', importType: '' };
const getFileTypeConfigResponse = {
payloadResponse: {
transactionSuccess: true,
fileTypeConfig: [
{
maxSize: '10',
allowedTxnExtn: ['CSV'],
allowedAttchmntExtn: ['ZIP']
}
],
isValueDateAllowed: false
}
};
const getFileTypeConfigRequest = { fileType: 'PAYMENT' };
describe.only('Bulk Import Tests', () => {
const wrapper = mount(<Import {...props} />);
const importFileType = mount(
<ImportFileType
onFileTypeChange={mockCallback}
fileTypes={fileTypes}
selectedFileType="PAYMENT"
/>
);
const importSwitch = mount(
<ImportSwitch
switchOptions={switchOptions}
switchChange={mockCallback}
hideSwitch={false}
/>
);
const fileTemplateSelect = mount(
<FileTemplateSelect
onFiletemplateChange={mockCallback}
fileTemplateOptions={fileTemplateOptions}
selectedfileTemplate=""
/>
);
it('Renders bulkImport', () => {
expect(wrapper.length).toEqual(1);
});
describe('FileUpload dropdown', () => {
it('should render File Upload Dropdown', () => {
expect(wrapper.find(Select).length).toBeGreaterThan(1);
});
it('Populates the fleTypes for File upload dropdown', () => {
expect(importFileType.props().fileTypes).toContain('PAYMENT');
});
it('Selects the first filetype as selected', () => {
expect(importFileType.props().selectedFileType).toBe('PAYMENT');
});
it('Should trigger onChange on FileType dropdown', () => {
importFileType.props().onFileTypeChange({ value: 'DirectDebit' });
expect(mockCallback).toHaveBeenCalledWith({ value: 'DirectDebit' });
});
});
describe('Import Switch', () => {
it('Renders Import Switch', () => {
expect(wrapper.find('ImportSwitch').length).toEqual(1);
});
it('Renders Switch Options', () => {
console.log(wrapper.state(), 'SWITCH OPTIONS====');
expect(importSwitch.props().switchOptions.length).toBe(2);
});
it('Display Switch card when both BulkImport and IH2H switch options available', () => {
expect(importSwitch.props().hideSwitch).toBeFalsy();
});
it('Should trigger onChange of Switch', () => {
importSwitch
.props()
.switchChange({ id: '1', label: 'IH2H', selected: true });
expect(mockCallback).toHaveBeenCalledWith({
id: '1',
label: 'IH2H',
selected: true
});
});
});
// describe('FiletemplateSelect', () => {
// // const wrapper = mount(<Import fileTemplateOptions={fileTemplateOptions}> )
// it('Renders FileTemplateSelect', () => {
// const importFileTypeWrapper = mount(
// <ImportFileType
// onFileTypeChange={mockCallback}
// fileTypes={fileTypes}
// selectedFileType="DirectDebit"
// />
// );
// expect(importFileTypeWrapper.props().selectedFileType).toEqual(
// 'DirectDebit'
// );
// expect(fileTemplateSelect.length).not.toEqual(1);
// });
// });
describe('Data FileUpload Tests', () => {
it('Renders Data File Upload', () => {
expect(wrapper.find('FileUpload').length).toEqual(1);
});
});
describe('Supporting Files Tests', () => {
it('Renders Supporting Files FileUpload', () => {
importFileType.props().onFileTypeChange({ value: 'Mandates' });
expect(mockCallback).toHaveBeenCalledWith({ value: 'Mandates' });
// expect(wrapper.find(ImportFiletype).props().selectedFileType).toEqual(
// 'Mandates'
// );
expect(wrapper.find('FileUpload').at(1).length).toEqual(1);
});
});
});
![]() |
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