Skip to content

Commit

Permalink
- deleted unneeded props
Browse files Browse the repository at this point in the history
- updated fetchAndValidateNr parameters
- updated unit tests
  • Loading branch information
Severin Beauvais committed Mar 26, 2024
1 parent 014972f commit 3cb1644
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 24 deletions.
6 changes: 1 addition & 5 deletions src/components/correct-name/CorrectNameRequest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ import { Component, Emit, Mixins, Prop, Watch } from 'vue-property-decorator'
import { NameRequestMixin } from '@bcrs-shared-components/mixins'
import { NameRequestIF } from '@bcrs-shared-components/interfaces'
import { CorrectNameOptions } from '@bcrs-shared-components/enums'
import { CorpTypeCd } from '@bcrs-shared-components/corp-type-module'
@Component({})
export default class CorrectNameRequest extends Mixins(NameRequestMixin) {
Expand All @@ -95,8 +94,6 @@ export default class CorrectNameRequest extends Mixins(NameRequestMixin) {
form: HTMLFormElement
}
@Prop({ required: true }) readonly businessId!: string
@Prop({ required: true }) readonly entityType!: CorpTypeCd // not used
@Prop({ required: true }) readonly fetchAndValidateNr!: (...args) => Promise<NameRequestIF>
@Prop({ required: true }) readonly formType!: CorrectNameOptions
@Prop({ required: true }) readonly nameRequest!: NameRequestIF
Expand Down Expand Up @@ -163,8 +160,7 @@ export default class CorrectNameRequest extends Mixins(NameRequestMixin) {
if (this.formType === CorrectNameOptions.CORRECT_NEW_NR) {
try {
// validate and return the name request data
const nr = await this.fetchAndValidateNr(this.nrNumber, this.businessId, this.applicantPhone,
this.applicantEmail)
const nr = await this.fetchAndValidateNr(this.nrNumber, this.applicantPhone, this.applicantEmail)
// emit new data
this.emitNameRequest(nr)
Expand Down
20 changes: 1 addition & 19 deletions tests/unit/CorrectNameRequest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,10 @@ const nameRequest = {
}
}

const fetchAndValidateNr = (nrNumber, businessId, applicantPhone, applicantEmail) => {
const fetchAndValidateNr = (nrNumber, applicantPhone, applicantEmail) => {
if (nrNumber !== nameRequest.nrNum) {
throw new Error('wrong NR number')
}
if (businessId && businessId !== nameRequest.corpNum) {
throw new Error('wrong business id')
}
if (applicantEmail && applicantEmail !== nameRequest.applicants.emailAddress) {
throw new Error('wrong applicant email')
}
Expand Down Expand Up @@ -255,21 +252,6 @@ describe('CorrectNameRequest', () => {
expect(getLastEvent(wrapper, 'saved')).toBe(false)
})

it('emits error and not saved when the process is done but business id doesn\'t match', async () => {
wrapper = wrapperFactory()

// Set values and submit form
wrapper.vm.nrNumber = 'NR 1234567'
await wrapper.setProps({ formType: 'correct-new-nr', businessId: 'BC0000000' })
await flushPromises()

expect(wrapper.vm.formValid).toBe(true)

// verify form emission
expect(getLastEvent(wrapper, 'error')).toBe('wrong business id')
expect(getLastEvent(wrapper, 'saved')).toBe(false)
})

it('emits done and verify data changes', async () => {
wrapper = wrapperFactory()

Expand Down

0 comments on commit 3cb1644

Please sign in to comment.