Skip to content

Commit

Permalink
Rebased + fixed Sev's comment + added unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JazzarKarim committed Jan 22, 2024
1 parent 54e1d98 commit 107e7c8
Show file tree
Hide file tree
Showing 4 changed files with 124 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 > 1) &&
(this.businesses.length >= 2) &&
this.businesses.every(business => business.status === AmlStatuses.OK)
)
}
Expand Down
119 changes: 119 additions & 0 deletions tests/unit/BusinessTable.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Vue from 'vue'
import { AmlRoles, AmlStatuses, AmlTypes } from '@/enums'
import { wrapperFactory } from '../vitest-wrapper-factory'
import BusinessTable from '@/components/Amalgamation/BusinessTable.vue'
Expand Down Expand Up @@ -169,6 +170,124 @@ describe('Business Table - display', () => {
}
})

describe('Business Table - validity', () => {
it('emit invalid when there are no businesses in the table', async () => {
const wrapper = wrapperFactory(
BusinessTable,
null,
{
amalgamation: {
amalgamatingBusinesses: []
}
}
)
await Vue.nextTick()

expect(wrapper.emitted('valid').pop()[0]).toEqual(false)
})

it('emit invalid when there is only one business in the table', async () => {
const wrapper = wrapperFactory(
BusinessTable,
null,
{
amalgamation: {
amalgamatingBusinesses: [
{
address: {
addressCity: 'Victoria',

Check failure on line 198 in tests/unit/BusinessTable.spec.ts

View workflow job for this annotation

GitHub Actions / linting (20.5.1)

Expected indentation of 16 spaces but found 18
addressCountry: 'CA',

Check failure on line 199 in tests/unit/BusinessTable.spec.ts

View workflow job for this annotation

GitHub Actions / linting (20.5.1)

Expected indentation of 16 spaces but found 18
addressRegion: 'BC',

Check failure on line 200 in tests/unit/BusinessTable.spec.ts

View workflow job for this annotation

GitHub Actions / linting (20.5.1)

Expected indentation of 16 spaces but found 18
addressType: 'mailing',

Check failure on line 201 in tests/unit/BusinessTable.spec.ts

View workflow job for this annotation

GitHub Actions / linting (20.5.1)

Expected indentation of 16 spaces but found 18
deliveryInstructions: '',

Check failure on line 202 in tests/unit/BusinessTable.spec.ts

View workflow job for this annotation

GitHub Actions / linting (20.5.1)

Expected indentation of 16 spaces but found 18
postalCode: 'X8Y 1X1',

Check failure on line 203 in tests/unit/BusinessTable.spec.ts

View workflow job for this annotation

GitHub Actions / linting (20.5.1)

Expected indentation of 16 spaces but found 18
streetAddress: 'test street',

Check failure on line 204 in tests/unit/BusinessTable.spec.ts

View workflow job for this annotation

GitHub Actions / linting (20.5.1)

Expected indentation of 16 spaces but found 18
streetAddressAdditional: ''

Check failure on line 205 in tests/unit/BusinessTable.spec.ts

View workflow job for this annotation

GitHub Actions / linting (20.5.1)

Expected indentation of 16 spaces but found 18
},
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
}
]
}
}
)
await Vue.nextTick()

expect(wrapper.emitted('valid').pop()[0]).toEqual(false)
})

it('emit valid when there are two or more businesses in the table', async () => {
const wrapper = wrapperFactory(
BusinessTable,
null,
{
amalgamation: {
amalgamatingBusinesses: [
{
address: {
addressCity: 'Victoria',

Check failure on line 237 in tests/unit/BusinessTable.spec.ts

View workflow job for this annotation

GitHub Actions / linting (20.5.1)

Expected indentation of 16 spaces but found 18
addressCountry: 'CA',

Check failure on line 238 in tests/unit/BusinessTable.spec.ts

View workflow job for this annotation

GitHub Actions / linting (20.5.1)

Expected indentation of 16 spaces but found 18
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
},
]
}
}
)
await Vue.nextTick()

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 107e7c8

Please sign in to comment.