Skip to content

Commit

Permalink
fix: #596 condition to check completed status (#672)
Browse files Browse the repository at this point in the history
* fix: condition to check completed status (#596)

* chore:  #596 add more test cases

Co-authored-by: Duong Pham <duongph@reapit.com>
  • Loading branch information
leXuanNha and Duong Pham committed Mar 20, 2020
1 parent 4970058 commit ee97cdc
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 32 deletions.
2 changes: 1 addition & 1 deletion packages/aml-checklist/src/tests/badges/badge-branches.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/elements/src/tests/badges/badge-branches.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/elements/src/tests/badges/badge-lines.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/elements/src/tests/badges/badge-statements.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {

describe('completed-sections', () => {
describe('isCompletedProfile', () => {
it('should run correctly', () => {
it('should return true', () => {
const params = {
title: 'Mr',
surname: 'A',
Expand All @@ -24,18 +24,52 @@ describe('completed-sections', () => {
expect(result).toBeTruthy()
})

it('should run correctly', () => {
it('should return false', () => {
const params = {
title: 'Mr',
surname: 'A',
forename: 'B',
dateOfBirth: '04/04/1996',
email: 'tanphamhaiduong@gmail.com',
}
const result = isCompletedProfile(params)
expect(result).toBeFalsy()
})

it('should return true', () => {
const params = {
title: 'Mr',
surname: 'A',
forename: 'B',
dateOfBirth: '04/04/1996',
homePhone: '0123456789',
}
const result = isCompletedProfile(params)
expect(result).toBeTruthy()
})

it('should return true', () => {
const params = {
title: 'Mr',
surname: 'A',
forename: 'B',
dateOfBirth: '04/04/1996',
workPhone: '0123456789',
}
const result = isCompletedProfile(params)
expect(result).toBeTruthy()
})

it('should return true', () => {
const params = {
title: 'Mr',
surname: 'A',
forename: 'B',
dateOfBirth: '04/04/1996',
mobilePhone: '0123456789',
}
const result = isCompletedProfile(params)
expect(result).toBeFalsy()
expect(result).toBeTruthy()
})

it('should run correctly', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ export const isCompletedProfile = (contact?: ContactModel | null) => {
contact?.surname &&
contact?.forename &&
contact?.dateOfBirth &&
contact?.homePhone &&
contact?.workPhone &&
contact?.mobilePhone &&
contact?.email
(contact?.homePhone || contact?.workPhone || contact?.mobilePhone)
return !!isValidProfile
}

Expand All @@ -33,32 +30,14 @@ export const isCompletedSecondaryID = (identityCheck?: IdentityCheckModel | null

export const isCompletedAddress = (contact?: ContactModel | null) => {
const isValidPrimaryAddress =
!!contact?.primaryAddress?.buildingName &&
!!contact?.primaryAddress?.buildingNumber &&
!!contact?.primaryAddress?.line1 &&
!!contact?.primaryAddress?.line2 &&
!!contact?.primaryAddress?.line3 &&
!!contact?.primaryAddress?.line4 &&
!!contact?.primaryAddress?.postcode &&
!!contact?.metadata?.primaryAddress?.year &&
!!contact?.metadata?.primaryAddress?.month &&
!!contact?.metadata?.primaryAddress?.documentType &&
!!contact?.metadata?.primaryAddress?.documentImage
const isValidSecondaryAddress =
!!contact?.secondaryAddress?.buildingName &&
!!contact?.secondaryAddress?.buildingNumber &&
!!contact?.secondaryAddress?.line1 &&
!!contact?.secondaryAddress?.line2 &&
!!contact?.secondaryAddress?.line3 &&
!!contact?.secondaryAddress?.line4 &&
!!contact?.metadata?.secondaryAddress?.year &&
!!contact?.metadata?.secondaryAddress?.month &&
!!contact?.metadata?.secondaryAddress?.documentType &&
!!contact?.metadata?.secondaryAddress?.documentImage

if (contact?.primaryAddress && !contact?.secondaryAddress) {
return !!isValidPrimaryAddress
}
return !!isValidPrimaryAddress && !!isValidSecondaryAddress
return !!isValidPrimaryAddress
}

export const isCompletedDeclarationRisk = (contact: ContactModel | null) => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ee97cdc

Please sign in to comment.