forked from bcgov/business-create-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- misc fixes - added Business Status unit tests - added Business Table unit tests - added Business Table Summary unit tests Co-authored-by: Severin Beauvais <severin.beauvais@gov.bc.ca>
- Loading branch information
1 parent
e691d3c
commit 4b5d4d7
Showing
7 changed files
with
426 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import { AmlStatuses } from '@/enums' | ||
import { wrapperFactory } from '../vitest-wrapper-factory' | ||
import BusinessStatus from '@/components/Amalgamation/BusinessStatus.vue' | ||
|
||
describe('Business Status', () => { | ||
const tests = [ | ||
{ | ||
label: 'OK', | ||
status: AmlStatuses.OK, | ||
tooltip: 'The currently selected BC Registries account has access to this business.' | ||
}, | ||
{ | ||
label: 'Error CCC Mismatch', | ||
status: AmlStatuses.ERROR_CCC_MISMATCH, | ||
tooltip: 'A BC Community Contribution Company must amalgamate to form a new BC Community' | ||
}, | ||
{ | ||
label: 'Error Foreign', | ||
status: AmlStatuses.ERROR_FOREIGN, | ||
tooltip: 'A foreign corporation cannot be amalgamated except by Registries staff.' | ||
}, | ||
{ | ||
label: 'Error Foreign Horizontal', | ||
status: AmlStatuses.ERROR_FOREIGN_HORIZONTAL, | ||
tooltip: 'A foreign company (including an Extraprovincial Company) cannot be part of a Short' | ||
}, | ||
{ | ||
label: 'Error Foreign Unlimited', | ||
status: AmlStatuses.ERROR_FOREIGN_UNLIMITED, | ||
tooltip: 'A foreign corporation must not amalgamate with a limited company and continue as' | ||
}, | ||
{ | ||
label: 'Error Foreign Unlimited 2', | ||
status: AmlStatuses.ERROR_FOREIGN_UNLIMITED2, | ||
tooltip: 'A BC Company cannot amalgamate with an existing foreign corporation to form a BC' | ||
}, | ||
{ | ||
label: 'Error Foreign Unlimited 3', | ||
status: AmlStatuses.ERROR_FOREIGN_UNLIMITED3, | ||
tooltip: 'A BC Company cannot amalgamate with a foreign company to form a BC Unlimited' | ||
}, | ||
{ | ||
label: 'Error Future Effective Filing', | ||
status: AmlStatuses.ERROR_FUTURE_EFFECTIVE_FILING, | ||
tooltip: 'This business has a future effective filing. It cannot be part of an amalgamation' | ||
}, | ||
{ | ||
label: 'Error Historical', | ||
status: AmlStatuses.ERROR_HISTORICAL, | ||
tooltip: 'This business is historical. It cannot be part of an amalgamation.' | ||
}, | ||
{ | ||
label: 'Error Limited Restoration', | ||
status: AmlStatuses.ERROR_LIMITED_RESTORATION, | ||
tooltip: 'This business is under limited restoration. It cannot be part of an amalgamation' | ||
}, | ||
{ | ||
label: 'Error Need BC Company', | ||
status: AmlStatuses.ERROR_NEED_BC_COMPANY, | ||
tooltip: 'You must add at least one BC company.' | ||
}, | ||
{ | ||
label: 'Error Not Affiliated', | ||
status: AmlStatuses.ERROR_NOT_AFFILIATED, | ||
tooltip: 'This business is not affiliated with the currently selected BC Registries account.' | ||
}, | ||
{ | ||
label: 'Error Not In Good Standing', | ||
status: AmlStatuses.ERROR_NOT_IN_GOOD_STANDING, | ||
tooltip: 'This business is not in good standing. This filing cannot be submitted until all' | ||
}, | ||
{ | ||
label: 'Error XPRO ULC CCC', | ||
status: AmlStatuses.ERROR_XPRO_ULC_CCC, | ||
tooltip: 'An Extraprovincial Company cannot amalgamate to form a new BC Unlimited Liability' | ||
} | ||
] | ||
|
||
it('has the expected number of tests', () => { | ||
expect(tests.length).toBe(14) | ||
}) | ||
|
||
for (const test of tests) { | ||
it(`correctly displays status "${test.label}"`, () => { | ||
const wrapper = wrapperFactory(BusinessStatus, { status: test.status }) | ||
|
||
const div = wrapper.find('.business-status') | ||
expect(div.exists()).toBe(true) | ||
|
||
// verify icon | ||
if (test.status === AmlStatuses.OK) { | ||
expect(div.find('.v-icon.mdi-check').exists()).toBe(true) | ||
} else { | ||
expect(div.find('.v-icon.mdi-alert').exists()).toBe(true) | ||
} | ||
|
||
// verify text | ||
if (test.status === AmlStatuses.OK) { | ||
expect(div.text()).toContain('Ready') | ||
} else { | ||
expect(div.text()).toContain('Attention Required') | ||
} | ||
|
||
// verify tooltip | ||
// (can't verify v-tooltip text directly because it's attached outside this component) | ||
expect((wrapper.vm as any).tooltip).toContain(test.tooltip) | ||
|
||
wrapper.destroy() | ||
}) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
import { AmlRoles, AmlTypes } from '@/enums' | ||
import { wrapperFactory } from '../vitest-wrapper-factory' | ||
import BusinessTable from '@/components/Amalgamation/BusinessTable.vue' | ||
import { CorpTypeCd } from '@bcrs-shared-components/corp-type-module' | ||
|
||
describe('Business Table', () => { | ||
it('displays correctly when there are no amalgamating businesses', () => { | ||
const wrapper = wrapperFactory( | ||
BusinessTable, | ||
null, | ||
{ | ||
amalgamation: { | ||
amalgamatingBusinesses: [] | ||
} | ||
} | ||
) | ||
|
||
const table = wrapper.find('#business-table') | ||
expect(table.exists()).toBe(true) | ||
|
||
// verify table headers | ||
const th = table.findAll('thead tr > th') | ||
expect(th.length).toBe(6) | ||
expect(th.at(0).text()).toBe('Business Name') | ||
expect(th.at(1).text()).toBe('Business Type') | ||
expect(th.at(2).text()).toBe('Mailing Address') | ||
expect(th.at(3).text()).toBe('Role') | ||
expect(th.at(4).text()).toBe('Status') | ||
expect(th.at(5).text()).toBe('Action') | ||
|
||
// verify table data | ||
const td = table.findAll('tbody tr > td') | ||
expect(td.length).toBe(1) | ||
expect(td.at(0).attributes('colspan')).toBe('6') | ||
expect(td.at(0).text()).toBe('No businesses added') | ||
|
||
wrapper.destroy() | ||
}) | ||
|
||
const amalgamatingBusinesses = [ | ||
{ | ||
label: 'BC Limited holding business', | ||
type: AmlTypes.LEAR, | ||
identifier: 'BC1111111', | ||
name: 'My BC Limited Company', | ||
email: 'bc1111111@example.com', | ||
address: { | ||
streetAddress: '123 Main St', | ||
addressCity: 'Victoria', | ||
addressCountry: 'CA', | ||
postalCode: 'V8V 8V8' | ||
}, | ||
legalType: CorpTypeCd.BC_COMPANY, | ||
expectedBusinessType: 'BC Limited Company', | ||
role: AmlRoles.HOLDING | ||
}, | ||
{ | ||
label: 'Benefit Company amalgamating business with no address', | ||
type: AmlTypes.LEAR, | ||
identifier: 'BC2222222', | ||
name: 'My Benefit Company', | ||
email: 'bc2222222@example.com', | ||
address: undefined, | ||
legalType: CorpTypeCd.BENEFIT_COMPANY, | ||
expectedBusinessType: 'BC Benefit Company', | ||
role: AmlRoles.AMALGAMATING | ||
}, | ||
{ | ||
label: 'foreign business in Federal jurisdiction', | ||
type: AmlTypes.FOREIGN, | ||
corpNumber: 'CA-3333333', | ||
legalName: 'My Federal Business', | ||
expectedBusinessType: 'Foreign', | ||
foreignJurisdiction: { | ||
country: 'CA', | ||
region: 'FEDERAL' | ||
}, | ||
expectedJurisdiction: 'Federal, Canada', | ||
role: AmlRoles.AMALGAMATING | ||
}, | ||
{ | ||
label: 'foreign business in USA jurisdiction', | ||
type: AmlTypes.FOREIGN, | ||
corpNumber: 'US-4444444', | ||
legalName: 'My USA Business', | ||
expectedBusinessType: 'Foreign', | ||
foreignJurisdiction: { | ||
country: 'US' | ||
}, | ||
expectedJurisdiction: 'United States of America', | ||
role: AmlRoles.AMALGAMATING | ||
} | ||
] | ||
|
||
for (const business of amalgamatingBusinesses) { | ||
it(`displays correctly when there is a ${business.label}`, () => { | ||
const wrapper = wrapperFactory( | ||
BusinessTable, | ||
null, | ||
{ | ||
amalgamation: { | ||
amalgamatingBusinesses: [ business ] | ||
} | ||
} | ||
) | ||
|
||
const table = wrapper.find('#business-table') | ||
expect(table.exists()).toBe(true) | ||
|
||
// verify table headers | ||
const th = table.findAll('thead tr > th') | ||
expect(th.length).toBe(6) | ||
expect(th.at(0).text()).toBe('Business Name') | ||
expect(th.at(1).text()).toBe('Business Type') | ||
expect(th.at(2).text()).toBe('Mailing Address') | ||
expect(th.at(3).text()).toBe('Role') | ||
expect(th.at(4).text()).toBe('Status') | ||
expect(th.at(5).text()).toBe('Action') | ||
|
||
// verify table data | ||
const td = table.findAll('tbody tr > td') | ||
expect(td.length).toBe(6) | ||
expect(td.at(0).classes('business-name')).toBe(true) | ||
expect(td.at(1).classes('business-type')).toBe(true) | ||
expect(td.at(2).classes('business-address')).toBe(true) | ||
expect(td.at(3).classes('business-role')).toBe(true) | ||
expect(td.at(4).classes('business-status')).toBe(true) | ||
expect(td.at(5).classes('business-actions')).toBe(true) | ||
|
||
if ((business.type === AmlTypes.LEAR)) { | ||
expect(td.at(0).text()).toContain(business.name) | ||
expect(td.at(0).text()).toContain(business.email) | ||
|
||
expect(td.at(1).text()).toContain(business.expectedBusinessType) | ||
|
||
if (business.address) { | ||
expect(td.at(2).text()).toContain(business.address.streetAddress) | ||
expect(td.at(2).text()).toContain(business.address.addressCity) | ||
expect(td.at(2).text()).toContain('Canada') | ||
expect(td.at(2).text()).toContain(business.address.postalCode) | ||
} else { | ||
expect(td.at(2).text()).toBe('Affiliate to view') | ||
} | ||
|
||
if (business.role === AmlRoles.AMALGAMATING) { | ||
expect(td.at(3).text()).toBe('Amalgamating Business') | ||
} | ||
if (business.role === AmlRoles.HOLDING) { | ||
expect(td.at(3).text()).toBe('Holding Company') | ||
} | ||
|
||
expect(td.at(4).exists()).toBe(true) // see separate BusinessTableStatus tests | ||
|
||
expect(td.at(5).find('.v-btn').exists()).toBe(true) | ||
} | ||
|
||
if ((business.type === AmlTypes.FOREIGN)) { | ||
expect(td.at(0).text()).toBe(business.legalName) | ||
expect(td.at(1).text()).toBe(business.expectedBusinessType) | ||
expect(td.at(2).text()).toBe(business.expectedJurisdiction) | ||
expect(td.at(3).text()).toBe('Amalgamating Business') | ||
expect(td.at(4).exists()).toBe(true) // see separate BusinessTableStatus tests | ||
expect(td.at(5).find('.v-btn').exists()).toBe(true) | ||
} | ||
|
||
wrapper.destroy() | ||
}) | ||
} | ||
}) |
Oops, something went wrong.