From 7ae92bf388a53da9e2f5b6cd4706247c543e947b Mon Sep 17 00:00:00 2001 From: Karim El Jazzar <122301442+JazzarKarim@users.noreply.github.com> Date: Mon, 22 Jan 2024 12:11:35 -0800 Subject: [PATCH] 19359 - Amalgamating Businesses Table must have more than 1 (#628) * Fixed amalgamating business length to be more than 1 * Rebased + fixed Sev's comment + added unit tests * Fixed lint issues * removed unneeded nextTick in tests --- package-lock.json | 6 +- package.json | 2 +- src/components/Amalgamation/BusinessTable.vue | 2 +- tests/unit/BusinessTable.spec.ts | 115 ++++++++++++++++++ 4 files changed, 120 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7e88bdf98..49db6d82d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "business-create-ui", - "version": "5.6.42", + "version": "5.6.43", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "business-create-ui", - "version": "5.6.42", + "version": "5.6.43", "dependencies": { "@babel/compat-data": "^7.21.5", "@bcrs-shared-components/approval-type": "1.0.19", @@ -74,7 +74,7 @@ "@typescript-eslint/eslint-plugin": "^5.59.2", "@typescript-eslint/parser": "^5.59.2", "@vitejs/plugin-vue2": "^2.2.0", - "@volar-plugins/vetur": "*", + "@volar-plugins/vetur": "latest", "@vue/eslint-config-standard": "^4.0.0", "@vue/eslint-config-typescript": "^9.1.0", "@vue/test-utils": "^1.3.5", diff --git a/package.json b/package.json index 54ede0961..f52776a85 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "business-create-ui", - "version": "5.6.42", + "version": "5.6.43", "private": true, "appName": "Create UI", "sbcName": "SBC Common Components", diff --git a/src/components/Amalgamation/BusinessTable.vue b/src/components/Amalgamation/BusinessTable.vue index 9ab90eff4..23f2f24f1 100644 --- a/src/components/Amalgamation/BusinessTable.vue +++ b/src/components/Amalgamation/BusinessTable.vue @@ -181,7 +181,7 @@ export default class BusinessTable extends Mixins(AmalgamationMixin) { @Emit('valid') private emitValidity (): boolean { return ( - (this.businesses.length > 0) && + (this.businesses.length >= 2) && this.businesses.every(business => business.status === AmlStatuses.OK) ) } diff --git a/tests/unit/BusinessTable.spec.ts b/tests/unit/BusinessTable.spec.ts index daba23698..aa52df203 100644 --- a/tests/unit/BusinessTable.spec.ts +++ b/tests/unit/BusinessTable.spec.ts @@ -169,6 +169,121 @@ describe('Business Table - display', () => { } }) +describe('Business Table - validity', () => { + it('emit invalid when there are no businesses in the table', () => { + const wrapper = wrapperFactory( + BusinessTable, + null, + { + amalgamation: { + amalgamatingBusinesses: [] + } + } + ) + + expect(wrapper.emitted('valid').pop()[0]).toEqual(false) + }) + + it('emit invalid when there is only one business in the table', () => { + const wrapper = wrapperFactory( + BusinessTable, + null, + { + amalgamation: { + amalgamatingBusinesses: [ + { + address: { + addressCity: 'Victoria', + addressCountry: 'CA', + addressRegion: 'BC', + addressType: 'mailing', + deliveryInstructions: '', + postalCode: 'X8Y 1X1', + streetAddress: 'test street', + streetAddressAdditional: '' + }, + email: 'no@reply.com', + identifier: 'BC1111111', + isFrozen: false, + isFutureEffective: false, + isLimitedRestoration: false, + isNotInGoodStanding: false, + legalType: CorpTypeCd.BENEFIT_COMPANY, + name: 'TEST BEN', + role: AmlRoles.AMALGAMATING, + status: AmlStatuses.OK, + type: AmlTypes.LEAR + } + ] + } + } + ) + + expect(wrapper.emitted('valid').pop()[0]).toEqual(false) + }) + + it('emit valid when there are two or more businesses in the table', () => { + const wrapper = wrapperFactory( + BusinessTable, + null, + { + amalgamation: { + amalgamatingBusinesses: [ + { + address: { + addressCity: 'Victoria', + addressCountry: 'CA', + addressRegion: 'BC', + addressType: 'mailing', + deliveryInstructions: '', + postalCode: 'X8Y 1X1', + streetAddress: 'test street', + streetAddressAdditional: '' + }, + email: 'no@reply.com', + identifier: 'BC1111111', + isFrozen: false, + isFutureEffective: false, + isLimitedRestoration: false, + isNotInGoodStanding: false, + legalType: CorpTypeCd.BENEFIT_COMPANY, + name: 'TEST BEN', + role: AmlRoles.AMALGAMATING, + status: AmlStatuses.OK, + type: AmlTypes.LEAR + }, + { + address: { + addressCity: 'Victoria', + addressCountry: 'CA', + addressRegion: 'BC', + addressType: 'mailing', + deliveryInstructions: '', + postalCode: 'X8Y 1X2', + streetAddress: 'test street 2', + streetAddressAdditional: '' + }, + email: 'no2@reply.com', + identifier: 'BC2222222', + isFrozen: false, + isFutureEffective: false, + isLimitedRestoration: false, + isNotInGoodStanding: false, + legalType: CorpTypeCd.BC_COMPANY, + name: 'TEST BEN NUMBER 2', + role: AmlRoles.AMALGAMATING, + status: AmlStatuses.OK, + type: AmlTypes.LEAR + } + ] + } + } + ) + + expect(wrapper.emitted('valid').pop()[0]).toBe(true) + }) +}) + // *** FUTURE: get this working // ATM, local rules are mocked (eg, wrapper.vm.notAffiliated()), but not the actual rules in the mixin. // It's probably this: https://vitest.dev/guide/mocking.html#mocking-pitfalls.