From a90303af7f6a34902d95ab0ab335a957d04c85a7 Mon Sep 17 00:00:00 2001 From: Severin Beauvais Date: Mon, 12 Feb 2024 15:50:38 -0800 Subject: [PATCH] - now filter adoptee businesses here instead of in shared component - added filter for entity type - added test suite --- package-lock.json | 8 +- package.json | 2 +- .../Amalgamation/ResultingBusinessName.vue | 27 ++++++- tests/unit/ResultingBusinessName.spec.ts | 73 +++++++++++++++++++ 4 files changed, 102 insertions(+), 8 deletions(-) create mode 100644 tests/unit/ResultingBusinessName.spec.ts diff --git a/package-lock.json b/package-lock.json index eaf7c9bb3..506a75e52 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "@bcrs-shared-components/confirm-dialog": "1.2.1", "@bcrs-shared-components/contact-info": "1.2.15", "@bcrs-shared-components/corp-type-module": "1.0.15", - "@bcrs-shared-components/correct-name": "1.0.40", + "@bcrs-shared-components/correct-name": "1.0.42", "@bcrs-shared-components/court-order-poa": "3.0.11", "@bcrs-shared-components/date-picker": "1.2.15", "@bcrs-shared-components/document-delivery": "1.2.0", @@ -326,9 +326,9 @@ "integrity": "sha512-g/TcNSR7zJsG2lBjn/NnM+/+k7dJzhAiy5PiPj0ObN56bUV1PrUWVVlg5lz4/JZUEAZetWhwnyAzPVGsn7kr1w==" }, "node_modules/@bcrs-shared-components/correct-name": { - "version": "1.0.40", - "resolved": "https://registry.npmjs.org/@bcrs-shared-components/correct-name/-/correct-name-1.0.40.tgz", - "integrity": "sha512-9ySmLiwq0n8fLfBNRJ9ayuNiv3eDmELSeqpU5Ce1m54hOceGE8RYQjyZoC7iS9Ln9BkeFMTTGwN5dyKb8yAktg==", + "version": "1.0.42", + "resolved": "https://registry.npmjs.org/@bcrs-shared-components/correct-name/-/correct-name-1.0.42.tgz", + "integrity": "sha512-f1Irq1qXlsKf52Zf0y5M0JPfwQfUcz8DUDB6d/S07NnKe1/5WsuQ10F/5/bIrEznKuNJpw5Qa2xWlCOl3U3SrA==", "dependencies": { "@bcrs-shared-components/confirm-dialog": "^1.2.3", "@bcrs-shared-components/corp-type-module": "^1.0.15", diff --git a/package.json b/package.json index bced21337..c461c6f9e 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "@bcrs-shared-components/confirm-dialog": "1.2.1", "@bcrs-shared-components/contact-info": "1.2.15", "@bcrs-shared-components/corp-type-module": "1.0.15", - "@bcrs-shared-components/correct-name": "1.0.40", + "@bcrs-shared-components/correct-name": "1.0.42", "@bcrs-shared-components/court-order-poa": "3.0.11", "@bcrs-shared-components/date-picker": "1.2.15", "@bcrs-shared-components/document-delivery": "1.2.0", diff --git a/src/components/Amalgamation/ResultingBusinessName.vue b/src/components/Amalgamation/ResultingBusinessName.vue index 6f9458298..b455c1670 100644 --- a/src/components/Amalgamation/ResultingBusinessName.vue +++ b/src/components/Amalgamation/ResultingBusinessName.vue @@ -27,7 +27,7 @@ > + (business.type !== AmlTypes.FOREIGN) && + ( + // check if entity types match + this.getEntityType === business.legalType || + ( + // allow BCs and BENs to match + [CorpTypeCd.BC_COMPANY, CorpTypeCd.BENEFIT_COMPANY].includes(this.getEntityType) && + [CorpTypeCd.BC_COMPANY, CorpTypeCd.BENEFIT_COMPANY].includes(business.legalType) + ) + ) + ) + } + /** The company name. */ get companyName (): string { return (this.getNameRequestApprovedName || this.getBusinessLegalName) diff --git a/tests/unit/ResultingBusinessName.spec.ts b/tests/unit/ResultingBusinessName.spec.ts new file mode 100644 index 000000000..37790d8af --- /dev/null +++ b/tests/unit/ResultingBusinessName.spec.ts @@ -0,0 +1,73 @@ +import { createPinia, setActivePinia } from 'pinia' +import { useStore } from '@/store/store' +import { shallowMount } from '@vue/test-utils' +import { AmlTypes } from '@/enums' +import { CorpTypeCd } from '@bcrs-shared-components/corp-type-module' +import ResultingBusinessName from '@/components/Amalgamation/ResultingBusinessName.vue' + +// mock the console.warn function to hide "[Vuetify] Unable to locate target XXX" +// console.warn = vi.fn() + +setActivePinia(createPinia()) +const store = useStore() + +describe('Resulting Business Name component', () => { + let wrapper: any + + beforeAll(() => { + wrapper = shallowMount(ResultingBusinessName) + }) + + afterAll(() => { + wrapper.destroy() + }) + + it('renders the component properly', () => { + expect(wrapper.find('#resulting-business-name').exists()).toBe(true) + }) + + const FOREIGN = { type: AmlTypes.FOREIGN } + const CCC = { type: AmlTypes.LEAR, legalType: CorpTypeCd.BC_CCC } + const BC = { type: AmlTypes.LEAR, legalType: CorpTypeCd.BC_COMPANY } + const BEN = { type: AmlTypes.LEAR, legalType: CorpTypeCd.BENEFIT_COMPANY } + const ULC = { type: AmlTypes.LEAR, legalType: CorpTypeCd.BC_ULC_COMPANY } + + const tests = [ + { // variation 0 + amalgamatingBusinesses: [ FOREIGN ], + computed: [] + }, + { // variation 1 + entityType: CorpTypeCd.BC_CCC, + amalgamatingBusinesses: [ BC, BEN, CCC, ULC ], + computed: [ CCC ] + }, + { // variation 2 + entityType: CorpTypeCd.BC_ULC_COMPANY, + amalgamatingBusinesses: [ BC, BEN, CCC, ULC ], + computed: [ ULC ] + }, + { // variation 3 + entityType: CorpTypeCd.BC_COMPANY, + amalgamatingBusinesses: [ BC, BEN, CCC, ULC ], + computed: [ BC, BEN ] + }, + { // variation 4 + entityType: CorpTypeCd.BENEFIT_COMPANY, + amalgamatingBusinesses: [ BC, BEN, CCC, ULC ], + computed: [ BC, BEN ] + } + ] + + for (let i = 0; i < tests.length; i++) { + const test = tests[i] + it(`correctly filters the list of amalgamating businesses - variation #${i}`, () => { + // set the entity type + store.setEntityType(test.entityType || null) + // set the amalgamating businesses + store.setAmalgamatingBusinesses(test.amalgamatingBusinesses as any[]) + // verify the computed value + expect(wrapper.vm.amalgamatingBusinesses).toEqual(test.computed) + }) + } +})