Skip to content

Commit

Permalink
19359 - Amalgamating Businesses Table must have more than 1 (#628)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
JazzarKarim authored Jan 22, 2024
1 parent fe44cf7 commit 7ae92bf
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 5 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Amalgamation/BusinessTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
}
Expand Down
115 changes: 115 additions & 0 deletions tests/unit/BusinessTable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '[email protected]',
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: '[email protected]',
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: '[email protected]',
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.
Expand Down

0 comments on commit 7ae92bf

Please sign in to comment.