Skip to content

Commit

Permalink
fix: #49 update backend change for lifetime legal app (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
duong-se authored Feb 11, 2020
1 parent d1405fa commit 46bdce7
Show file tree
Hide file tree
Showing 22 changed files with 374 additions and 53 deletions.
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 @@ -3,14 +3,33 @@ import { combineAddress } from '../combine-address'
describe('combineAddress', () => {
it('should run correctly', () => {
const address = {
buildingName: '',
buildingName: '123',
buildingNumber: '65',
line1: 'Lindsey Close',
line2: 'Great Denham',
line3: 'Bedford',
line4: 'Bedfordshire',
postcode: 'MK40 4GT',
country: '',
country: 'GB',
geolocation: {
latitude: 52.1284,
longitude: -0.507145,
},
}
const result = combineAddress(address)
const expected = '65 123 Lindsey Close Great Denham Bedford Bedfordshire MK40 4GT'
expect(result).toEqual(expected)
})

it('should run correctly 1', () => {
const address = {
buildingNumber: '65',
line1: 'Lindsey Close',
line2: 'Great Denham',
line3: 'Bedford',
line4: 'Bedfordshire',
postcode: 'MK40 4GT',
country: 'GB',
geolocation: {
latitude: 52.1284,
longitude: -0.507145,
Expand All @@ -20,4 +39,137 @@ describe('combineAddress', () => {
const expected = '65 Lindsey Close Great Denham Bedford Bedfordshire MK40 4GT'
expect(result).toEqual(expected)
})

it('should run correctly 2', () => {
const address = {
buildingName: '123',
line1: 'Lindsey Close',
line2: 'Great Denham',
line3: 'Bedford',
line4: 'Bedfordshire',
postcode: 'MK40 4GT',
country: 'GB',
geolocation: {
latitude: 52.1284,
longitude: -0.507145,
},
}
const result = combineAddress(address)
const expected = ' 123 Lindsey Close Great Denham Bedford Bedfordshire MK40 4GT'
expect(result).toEqual(expected)
})

it('should run correctly 3', () => {
const address = {
buildingName: '123',
buildingNumber: '65',
line2: 'Great Denham',
line3: 'Bedford',
line4: 'Bedfordshire',
postcode: 'MK40 4GT',
country: 'GB',
geolocation: {
latitude: 52.1284,
longitude: -0.507145,
},
}
const result = combineAddress(address)
const expected = '65 123 Great Denham Bedford Bedfordshire MK40 4GT'
expect(result).toEqual(expected)
})

it('should run correctly 4', () => {
const address = {
buildingName: '123',
buildingNumber: '65',
line1: 'Lindsey Close',
line3: 'Bedford',
line4: 'Bedfordshire',
postcode: 'MK40 4GT',
country: 'GB',
geolocation: {
latitude: 52.1284,
longitude: -0.507145,
},
}
const result = combineAddress(address)
const expected = '65 123 Lindsey Close Bedford Bedfordshire MK40 4GT'
expect(result).toEqual(expected)
})

it('should run correctly 5', () => {
const address = {
buildingName: '123',
buildingNumber: '65',
line1: 'Lindsey Close',
line2: 'Great Denham',
line4: 'Bedfordshire',
postcode: 'MK40 4GT',
country: 'GB',
geolocation: {
latitude: 52.1284,
longitude: -0.507145,
},
}
const result = combineAddress(address)
const expected = '65 123 Lindsey Close Great Denham Bedfordshire MK40 4GT'
expect(result).toEqual(expected)
})

it('should run correctly 6', () => {
const address = {
buildingName: '123',
buildingNumber: '65',
line1: 'Lindsey Close',
line2: 'Great Denham',
line3: 'Bedford',
postcode: 'MK40 4GT',
country: 'GB',
geolocation: {
latitude: 52.1284,
longitude: -0.507145,
},
}
const result = combineAddress(address)
const expected = '65 123 Lindsey Close Great Denham Bedford MK40 4GT'
expect(result).toEqual(expected)
})

it('should run correctly 7', () => {
const address = {
buildingName: '123',
buildingNumber: '65',
line1: 'Lindsey Close',
line2: 'Great Denham',
line3: 'Bedford',
line4: 'Bedfordshire',
country: 'GB',
geolocation: {
latitude: 52.1284,
longitude: -0.507145,
},
}
const result = combineAddress(address)
const expected = '65 123 Lindsey Close Great Denham Bedford Bedfordshire'
expect(result).toEqual(expected)
})

it('should run correctly 8', () => {
const address = {
buildingName: '123',
buildingNumber: '65',
line1: 'Lindsey Close',
line2: 'Great Denham',
line3: 'Bedford',
line4: 'Bedfordshire',
postcode: 'MK40 4GT',
geolocation: {
latitude: 52.1284,
longitude: -0.507145,
},
}
const result = combineAddress(address)
const expected = '65 123 Lindsey Close Great Denham Bedford Bedfordshire MK40 4GT'
expect(result).toEqual(expected)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('completed-sections', () => {
})

it('should run correctly', () => {
const params = null
const params = undefined
const result = isCompletedProfile(params)
expect(result).toBeFalsy()
})
Expand Down Expand Up @@ -217,6 +217,118 @@ describe('completed-sections', () => {
const result = isCompletedAddress(params)
expect(result).toBeTruthy()
})

it('should run correctly', () => {
const params = {
id: 'BED16000182',
created: '2019-04-18T06:56:07.0000000Z',
title: 'Ms',
forename: 'Cerys',
surname: 'Haldane',
active: true,
marketingConsent: 'notAsked',
source: {
id: '',
type: '',
},
homePhone: '01632 963892',
workPhone: '020 7946 3892',
mobilePhone: '07700 903892',
email: '[email protected]',
primaryAddress: {
type: 'primary',
buildingName: '123',
buildingNumber: '102',
line1: 'Holwelbury Road',
line2: '123',
line3: '123',
line4: '123',
postcode: 'SG5 3FL',
countryId: 'GB',
},
secondaryAddress: {
type: 'secondary',
buildingName: '123',
buildingNumber: '102',
line1: 'Holwelbury Road',
line2: '123',
line3: '123',
line4: '123',
postcode: 'SG5 3FL',
countryId: 'GB',
},
officeIds: ['BED'],
negotiatorIds: ['JWB'],
_links: {
self: {
href: '/contacts/BED16000182',
},
documents: {
href: '/documents/?OwnerType=contact&OwnerId=BED16000182',
},
identityChecks: {
href: '/identityChecks/?ContactId=BED16000182',
},
},
}
const result = isCompletedAddress(params)
expect(result).toBeTruthy()
})

it('should run correctly', () => {
const params = {
id: 'BED16000182',
created: '2019-04-18T06:56:07.0000000Z',
title: 'Ms',
forename: 'Cerys',
surname: 'Haldane',
active: true,
marketingConsent: 'notAsked',
source: {
id: '',
type: '',
},
homePhone: '01632 963892',
workPhone: '020 7946 3892',
mobilePhone: '07700 903892',
email: '[email protected]',
primaryAddress: {
type: 'primary',
buildingName: '123',
buildingNumber: '102',
line1: 'Holwelbury Road',
line2: '123',
line3: '123',
line4: '123',
postcode: 'SG5 3FL',
countryId: 'GB',
},
secondaryAddress: {
type: 'secondary',
buildingName: '123',
buildingNumber: '102',
line1: 'Holwelbury Road',
line4: '123',
postcode: 'SG5 3FL',
countryId: 'GB',
},
officeIds: ['BED'],
negotiatorIds: ['JWB'],
_links: {
self: {
href: '/contacts/BED16000182',
},
documents: {
href: '/documents/?OwnerType=contact&OwnerId=BED16000182',
},
identityChecks: {
href: '/identityChecks/?ContactId=BED16000182',
},
},
}
const result = isCompletedAddress(params)
expect(result).toBeFalsy()
})
})

describe('isCompletedDeclarationRisk', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ContactModel, IdentityCheckModel } from '@reapit/foundations-ts-definitions'

export const isCompletedProfile = (contact: ContactModel | null) => {
export const isCompletedProfile = (contact?: ContactModel | null) => {
const isValidProfile =
contact?.title &&
contact?.surname &&
Expand All @@ -13,7 +13,7 @@ export const isCompletedProfile = (contact: ContactModel | null) => {
return !!isValidProfile
}

export const isCompletedPrimaryID = (identityCheck: IdentityCheckModel | null) => {
export const isCompletedPrimaryID = (identityCheck?: IdentityCheckModel | null) => {
const isValidIdentityCheck =
identityCheck?.identityDocument1?.details &&
identityCheck?.identityDocument1?.documentId &&
Expand All @@ -22,7 +22,7 @@ export const isCompletedPrimaryID = (identityCheck: IdentityCheckModel | null) =
return !!isValidIdentityCheck
}

export const isCompletedSecondaryID = (identityCheck: IdentityCheckModel | null) => {
export const isCompletedSecondaryID = (identityCheck?: IdentityCheckModel | null) => {
const isValidIdentityCheck =
identityCheck?.identityDocument2?.details &&
identityCheck?.identityDocument2?.documentId &&
Expand All @@ -31,7 +31,7 @@ export const isCompletedSecondaryID = (identityCheck: IdentityCheckModel | null)
return !!isValidIdentityCheck
}

export const isCompletedAddress = (contact: ContactModel | null) => {
export const isCompletedAddress = (contact?: ContactModel | null) => {
const isValidPrimaryAddress =
contact?.primaryAddress?.buildingName &&
contact?.primaryAddress?.buildingNumber &&
Expand Down
1 change: 1 addition & 0 deletions packages/elements/src/utils/datetime/datetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const DATE_TIME_FORMAT = {
RFC3339: 'YYYY-MM-DDTHH:mm:ssZ',
DATE_FORMAT: 'DD MMM YYYY',
DATE_TIME_FORMAT: 'DD MMM YYYY HH:mm',
DATE_FORMAT_1: 'YYYY-MM-DD',
}

export function getTime(date: dayjs.ConfigType, is24HourTime: boolean = false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,9 @@ describe('fieldValidateRequire', () => {
const value = ''
expect(fieldValidateRequire(value)).toStrictEqual(errorMessages.FIELD_REQUIRED)
})

it('work correctly', () => {
const value = '123'
expect(fieldValidateRequire(value)).toBeNull()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@ export interface CreateAppModel {
* Sets the apps uri where a user will be redirected to immediately after a successful authentication. Multiple URIs can be passed as a comma separated list
*/
redirectUris?: string[]

/**
* Sets the unique identifer of the developer registering the app
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`PrimaryIdentification PrimaryIdentification should match snapshot 1`] =
<Component
contactModel={
Object {
"_eTag": "9CBE436919C6BE89A8642BC70A7CFAEE",
"_eTag": "\\"9CBE436919C6BE89A8642BC70A7CFAEE\\"",
"_embedded": Object {},
"_links": Object {
"documents": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`SecondaryIdentification SecondaryIdentification should match snapshot 1
<Component
contactModel={
Object {
"_eTag": "9CBE436919C6BE89A8642BC70A7CFAEE",
"_eTag": "\\"9CBE436919C6BE89A8642BC70A7CFAEE\\"",
"_embedded": Object {},
"_links": Object {
"documents": Object {
Expand Down
Loading

0 comments on commit 46bdce7

Please sign in to comment.