From 22833e247e06d80da0ca85d0c9a2a741b5ed8bad Mon Sep 17 00:00:00 2001 From: eve-git Date: Mon, 24 Apr 2023 14:44:44 -0700 Subject: [PATCH 1/4] validate NR --- package-lock.json | 4 +-- package.json | 2 +- .../CompanyName/CorrectNameRequest.vue | 8 +++-- tests/unit/CorrectNameRequest.spec.ts | 33 +++++++++++++++++++ 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index ea3f8fba6..738e835ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "business-edit-ui", - "version": "4.3.3", + "version": "4.3.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "business-edit-ui", - "version": "4.3.3", + "version": "4.3.4", "dependencies": { "@babel/compat-data": "^7.19.1", "@bcrs-shared-components/action-chip": "1.1.5", diff --git a/package.json b/package.json index 09e63d92e..6d9be50e8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "business-edit-ui", - "version": "4.3.3", + "version": "4.3.4", "private": true, "appName": "Edit UI", "sbcName": "SBC Common Components", diff --git a/src/components/common/YourCompany/CompanyName/CorrectNameRequest.vue b/src/components/common/YourCompany/CompanyName/CorrectNameRequest.vue index 6f91bbc71..8eb385e11 100644 --- a/src/components/common/YourCompany/CompanyName/CorrectNameRequest.vue +++ b/src/components/common/YourCompany/CompanyName/CorrectNameRequest.vue @@ -166,8 +166,12 @@ export default class CorrectNameRequest extends Mixins(CommonMixin, NameRequestM } private isValidNrNumber (value: string): boolean { - const VALID_FORMAT = new RegExp(/^(NR )\d{7}$/) - return VALID_FORMAT.test(value) + const VALID_FORMAT = new RegExp(/^(NR)?\s*(\d{7})$/) + if (VALID_FORMAT.test(value)) { + this.nameRequestNumber = 'NR ' + value.match(VALID_FORMAT)[2] + return true + } + return false } private validateEmailFormat (value: string): boolean { diff --git a/tests/unit/CorrectNameRequest.spec.ts b/tests/unit/CorrectNameRequest.spec.ts index cd1d390e6..7c550ac34 100644 --- a/tests/unit/CorrectNameRequest.spec.ts +++ b/tests/unit/CorrectNameRequest.spec.ts @@ -76,6 +76,39 @@ describe('CorrectNameRequest', () => { await flushPromises() expect(wrapper.vm.isFormValid).toBe(true) + expect(wrapper.vm.nameRequestNumber).toEqual('NR 1234567') + }) + + it('verifies inputs when valid', async () => { + const wrapper = wrapperFactory() + + // Verify Invalid before input + expect(wrapper.vm.isFormValid).toBe(false) + + wrapper.vm.nameRequestNumber = 'NR 1234567' + wrapper.vm.applicantPhone = '123 456 7890' + wrapper.vm.applicantEmail = 'mock@example.com' + + await flushPromises() + + expect(wrapper.vm.isFormValid).toBe(true) + expect(wrapper.vm.nameRequestNumber).toEqual('NR 1234567') + }) + + it('verifies inputs when valid', async () => { + const wrapper = wrapperFactory() + + // Verify Invalid before input + expect(wrapper.vm.isFormValid).toBe(false) + + wrapper.vm.nameRequestNumber = '1234567' + wrapper.vm.applicantPhone = '123 456 7890' + wrapper.vm.applicantEmail = 'mock@example.com' + + await flushPromises() + + expect(wrapper.vm.isFormValid).toBe(true) + expect(wrapper.vm.nameRequestNumber).toEqual('NR 1234567') }) it('verifies invalid NR', async () => { From 0ed1b78a97e5161d16a650293a728ede63b0895c Mon Sep 17 00:00:00 2001 From: eve-git Date: Mon, 24 Apr 2023 15:34:03 -0700 Subject: [PATCH 2/4] validate NR --- tests/unit/CorrectNameRequest.spec.ts | 49 +++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/unit/CorrectNameRequest.spec.ts b/tests/unit/CorrectNameRequest.spec.ts index 7c550ac34..f42612fe6 100644 --- a/tests/unit/CorrectNameRequest.spec.ts +++ b/tests/unit/CorrectNameRequest.spec.ts @@ -111,6 +111,23 @@ describe('CorrectNameRequest', () => { expect(wrapper.vm.nameRequestNumber).toEqual('NR 1234567') }) + // the spaces between 'NR' and the numbers is ignored + it('verifies valid NR input', async () => { + const wrapper = wrapperFactory() + + // Verify Invalid before input + expect(wrapper.vm.isFormValid).toBe(false) + + wrapper.vm.nameRequestNumber = 'NR 1234567' + wrapper.vm.applicantPhone = '123 456 7890' + wrapper.vm.applicantEmail = 'mock@example.com' + + await flushPromises() + + expect(wrapper.vm.isFormValid).toBe(true) + expect(wrapper.vm.nameRequestNumber).toEqual('NR 1234567') + }) + it('verifies invalid NR', async () => { const wrapper = wrapperFactory() @@ -125,6 +142,38 @@ describe('CorrectNameRequest', () => { expect(wrapper.vm.isFormValid).toBe(false) }) + // the leading or tearing spaces of a NR are invalid + it('verifies invalid NR', async () => { + const wrapper = wrapperFactory() + + // Verify Invalid before input + expect(wrapper.vm.isFormValid).toBe(false) + + wrapper.vm.nameRequestNumber = ' NR 1234567' + wrapper.vm.applicantPhone = '123 456 7890' + wrapper.vm.applicantEmail = 'mock@example.com' + + await flushPromises() + + expect(wrapper.vm.isFormValid).toBe(false) + }) + + // the leading or tearing spaces are invalid + it('verifies invalid NR', async () => { + const wrapper = wrapperFactory() + + // Verify Invalid before input + expect(wrapper.vm.isFormValid).toBe(false) + + wrapper.vm.nameRequestNumber = 'NR 1234567 ' + wrapper.vm.applicantPhone = '123 456 7890' + wrapper.vm.applicantEmail = 'mock@example.com' + + await flushPromises() + + expect(wrapper.vm.isFormValid).toBe(false) + }) + it('verifies invalid email', async () => { const wrapper = wrapperFactory() From ae09408e4c8acdcf952970df596511e24e946e95 Mon Sep 17 00:00:00 2001 From: eve-git Date: Mon, 24 Apr 2023 15:36:05 -0700 Subject: [PATCH 3/4] validate NR --- tests/unit/CorrectNameRequest.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/CorrectNameRequest.spec.ts b/tests/unit/CorrectNameRequest.spec.ts index f42612fe6..ff7759f37 100644 --- a/tests/unit/CorrectNameRequest.spec.ts +++ b/tests/unit/CorrectNameRequest.spec.ts @@ -111,7 +111,7 @@ describe('CorrectNameRequest', () => { expect(wrapper.vm.nameRequestNumber).toEqual('NR 1234567') }) - // the spaces between 'NR' and the numbers is ignored + // the spaces between 'NR' and the numbers are ignored it('verifies valid NR input', async () => { const wrapper = wrapperFactory() From 20961fe70c3cab0b58c8947429176858689429ac Mon Sep 17 00:00:00 2001 From: eve-git Date: Wed, 26 Apr 2023 09:30:46 -0700 Subject: [PATCH 4/4] typo --- tests/unit/CorrectNameRequest.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/CorrectNameRequest.spec.ts b/tests/unit/CorrectNameRequest.spec.ts index ff7759f37..8c9e534a7 100644 --- a/tests/unit/CorrectNameRequest.spec.ts +++ b/tests/unit/CorrectNameRequest.spec.ts @@ -142,7 +142,7 @@ describe('CorrectNameRequest', () => { expect(wrapper.vm.isFormValid).toBe(false) }) - // the leading or tearing spaces of a NR are invalid + // the leading or trailing spaces of a NR are invalid it('verifies invalid NR', async () => { const wrapper = wrapperFactory() @@ -158,7 +158,7 @@ describe('CorrectNameRequest', () => { expect(wrapper.vm.isFormValid).toBe(false) }) - // the leading or tearing spaces are invalid + // the leading or trailing spaces are invalid it('verifies invalid NR', async () => { const wrapper = wrapperFactory()