Skip to content

Commit

Permalink
- now filter adoptee businesses here instead of in shared component
Browse files Browse the repository at this point in the history
- added filter for entity type
- added test suite
  • Loading branch information
Severin Beauvais committed Feb 12, 2024
1 parent facee84 commit a90303a
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 8 deletions.
8 changes: 4 additions & 4 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
Expand Up @@ -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",
Expand Down
27 changes: 24 additions & 3 deletions src/components/Amalgamation/ResultingBusinessName.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
>
<CorrectName
actionTxt="choose the resulting business name"
:amalgamatingBusinesses="getAmalgamatingBusinesses"
:amalgamatingBusinesses="amalgamatingBusinesses"
:businessId="getBusinessId"
:companyName="companyName"
:correctionNameChoices="correctionNameChoices"
Expand Down Expand Up @@ -71,14 +71,15 @@
import { Component, Mixins } from 'vue-property-decorator'
import { Getter } from 'pinia-class'
import { useStore } from '@/store/store'
import { AmlTypes } from '@/enums'
import { AmalgamationMixin, NameRequestMixin } from '@/mixins/'
import { NameRequestIF } from '@/interfaces/'
import { AmalgamatingBusinessIF, NameRequestIF } from '@/interfaces/'
import { LegalServices } from '@/services/'
import { CorrectNameOptions, NrRequestActionCodes } from '@bcrs-shared-components/enums/'
import { CorrectName } from '@bcrs-shared-components/correct-name/'
import NameRequestInfo from '@/components/common/NameRequestInfo.vue'
import NameTranslations from '@/components/common/NameTranslations.vue'
import { AmlTypes } from '@/enums'
import { CorpTypeCd } from '@bcrs-shared-components/corp-type-module'
@Component({
components: {
Expand All @@ -92,6 +93,7 @@ export default class ResultingBusinessName extends Mixins(AmalgamationMixin, Nam
@Getter(useStore) getBusinessId!: string
@Getter(useStore) getBusinessLegalName!: string
@Getter(useStore) getCorrectNameOption!: CorrectNameOptions
// @Getter(useStore) getEntityType!: CorpTypeCd
@Getter(useStore) getNameRequest!: NameRequestIF
@Getter(useStore) getNameRequestApprovedName!: string
@Getter(useStore) getNameRequestNumber!: string
Expand All @@ -109,6 +111,25 @@ export default class ResultingBusinessName extends Mixins(AmalgamationMixin, Nam
CorrectNameOptions.CORRECT_AML_NUMBERED
]
/**
* The list of amalgamating businesses, excluding foreigns and including only businesses of a
* compatible entity type: ULC to ULC, LTD to LTD, and CCC to CCC.
*/
get amalgamatingBusinesses (): AmalgamatingBusinessIF[] {
return this.getAmalgamatingBusinesses.filter(business =>
(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)
Expand Down
73 changes: 73 additions & 0 deletions tests/unit/ResultingBusinessName.spec.ts
Original file line number Diff line number Diff line change
@@ -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)
})
}
})

0 comments on commit a90303a

Please sign in to comment.