89 lines
3.9 KiB
TypeScript
89 lines
3.9 KiB
TypeScript
/**
|
|
* Copyright since 2025 Mifos Initiative
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
import { ENTITY_KYC_CATEGORY, ENTITY_KYC_DOCUMENT_TYPES, withEntityKycDocuments } from './entity-kyc-documents';
|
|
|
|
describe('withEntityKycDocuments', () => {
|
|
const names = (docs: { name: string }[]) => docs.map((d) => d.name);
|
|
|
|
it('keeps the six RBI entity documents when nothing else is supplied', () => {
|
|
expect(names(withEntityKycDocuments())).toEqual(names(ENTITY_KYC_DOCUMENT_TYPES));
|
|
});
|
|
|
|
it('puts the entity documents ahead of anything the caller adds', () => {
|
|
const merged = withEntityKycDocuments([{ name: 'Declaration by Karta', mandatory: true }], 'HUF');
|
|
expect(names(merged.slice(0, 6))).toEqual(names(ENTITY_KYC_DOCUMENT_TYPES));
|
|
expect(merged[6].name).toBe('Declaration by Karta');
|
|
});
|
|
|
|
it('groups the entity documents together and the rest under the constitution', () => {
|
|
const merged = withEntityKycDocuments([{ name: 'Declaration by Karta' }], 'HUF');
|
|
expect(merged[0].category).toBe(ENTITY_KYC_CATEGORY);
|
|
expect(merged[6].category).toBe('HUF documents');
|
|
});
|
|
|
|
it('folds the backend template names onto the entity chips instead of duplicating them', () => {
|
|
const merged = withEntityKycDocuments(
|
|
[
|
|
{ name: 'Certificate of Incorporation', code: 'COI', mandatory: true },
|
|
{ name: 'Memorandum of Association', code: 'MOA', mandatory: true },
|
|
{ name: 'Articles of Association', code: 'AOA', mandatory: true },
|
|
{ name: 'PAN Card of Company', code: 'PAN', mandatory: true },
|
|
{ name: 'Board Resolution', code: 'BOARD_RESOLUTION', mandatory: true },
|
|
{ name: 'KYC of Authorized Signatories', code: 'SIGNATORY_KYC', mandatory: true }
|
|
],
|
|
'Private Limited Company'
|
|
);
|
|
expect(merged).toHaveLength(6);
|
|
expect(names(merged)).toEqual(names(ENTITY_KYC_DOCUMENT_TYPES));
|
|
});
|
|
|
|
it('folds constitution labels on too, since those lists carry no codes', () => {
|
|
const merged = withEntityKycDocuments(
|
|
[
|
|
{ name: 'Certificate of Incorporation', code: 'Certificate of Incorporation', mandatory: true },
|
|
{ name: 'LLP Agreement', code: 'LLP Agreement', mandatory: true },
|
|
{ name: 'PAN of LLP', code: 'PAN of LLP', mandatory: true },
|
|
{ name: 'Designated Partners Resolution', code: 'Designated Partners Resolution', mandatory: true },
|
|
{ name: 'KYC of Designated Partners / Authorized Signatories', code: 'x', mandatory: true }
|
|
],
|
|
'Limited Liability Partnership (LLP)'
|
|
);
|
|
expect(merged).toHaveLength(6);
|
|
});
|
|
|
|
it('carries a mandatory flag over to the entity document it folds into', () => {
|
|
const merged = withEntityKycDocuments([{ name: 'PAN Card of Company', code: 'PAN', mandatory: true }]);
|
|
expect(merged.find((d) => d.code === 'ENTITY_PAN')?.mandatory).toBe(true);
|
|
expect(merged.find((d) => d.code === 'GST_CERTIFICATE')?.mandatory).toBe(false);
|
|
});
|
|
|
|
it('keeps a document that only mentions another one as its own requirement', () => {
|
|
const merged = withEntityKycDocuments(
|
|
[{ name: 'Proof of Business Existence (GST Certificate / Shop License)', mandatory: true }],
|
|
'Sole Proprietorship'
|
|
);
|
|
expect(names(merged)).toContain('Proof of Business Existence (GST Certificate / Shop License)');
|
|
});
|
|
|
|
it('keeps constitution-specific requirements the entity list does not cover', () => {
|
|
const merged = withEntityKycDocuments(
|
|
[
|
|
{ name: 'Government Notification / Order', mandatory: true },
|
|
{ name: 'Udyam Registration Certificate', code: 'UDYAM', mandatory: true },
|
|
{ name: 'Proof of Address of HUF' }],
|
|
'Government Body / PSU'
|
|
);
|
|
expect(names(merged).slice(6)).toEqual([
|
|
'Government Notification / Order',
|
|
'Udyam Registration Certificate',
|
|
'Proof of Address of HUF'
|
|
]);
|
|
});
|
|
});
|