-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add trim for all properties of the identify
- Loading branch information
Showing
4 changed files
with
151 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
import saveIdentity, { formatIdentityContact } from './saveIdentity' | ||
import saveIdentity, { | ||
formatIdentityContact, | ||
trimProperties | ||
} from './saveIdentity' | ||
|
||
describe('saveIdentity', function () { | ||
const client = { | ||
|
@@ -152,3 +155,63 @@ describe('formatIdentityContact', () => { | |
expect(formattedContact).toEqual(expectedContact) | ||
}) | ||
}) | ||
|
||
describe('trimProperties', () => { | ||
it('should trim all properties', () => { | ||
const contact = { | ||
address: [ | ||
{ | ||
city: ' CITY', | ||
formattedAddress: '86 CHEMIN DES DAMES 01001 CITY ', | ||
postCode: '01001', | ||
street: { | ||
streetName: ' DES DAMES', | ||
streetNumber: 86, | ||
streetType: 'CHEMIN' | ||
} | ||
} | ||
], | ||
email: ' [email protected] ', | ||
name: { | ||
firstName: 'Chris', | ||
fullName: 'Chris A', | ||
lastName: 'A' | ||
}, | ||
phoneNumber: [ | ||
{ | ||
number: ' 060606060606', | ||
type: 'mobile' | ||
} | ||
] | ||
} | ||
|
||
const expectedContact = { | ||
address: [ | ||
{ | ||
city: 'CITY', | ||
formattedAddress: '86 CHEMIN DES DAMES 01001 CITY', | ||
postCode: '01001', | ||
street: { | ||
streetName: 'DES DAMES', | ||
streetNumber: 86, | ||
streetType: 'CHEMIN' | ||
} | ||
} | ||
], | ||
email: '[email protected]', | ||
name: { | ||
firstName: 'Chris', | ||
fullName: 'Chris A', | ||
lastName: 'A' | ||
}, | ||
phoneNumber: [ | ||
{ | ||
number: '060606060606', | ||
type: 'mobile' | ||
} | ||
] | ||
} | ||
|
||
expect(trimProperties(contact)).toEqual(expectedContact) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ jest.mock('./cozyclient', () => ({ | |
const updateOrCreate = require('./updateOrCreate') | ||
const saveIdentity = require('./saveIdentity').saveIdentity | ||
const formatIdentityContact = require('./saveIdentity').formatIdentityContact | ||
const trimProperties = require('./saveIdentity').trimProperties | ||
const cozyClient = require('./cozyclient') | ||
|
||
describe('saveIdentity', () => { | ||
|
@@ -132,3 +133,63 @@ describe('formatIdentityContact', () => { | |
expect(formattedContact).toEqual(expectedContact) | ||
}) | ||
}) | ||
|
||
describe('trimProperties', () => { | ||
it('should trim all properties', () => { | ||
const contact = { | ||
address: [ | ||
{ | ||
city: ' CITY', | ||
formattedAddress: '86 CHEMIN DES DAMES 01001 CITY ', | ||
postCode: '01001', | ||
street: { | ||
streetName: ' DES DAMES', | ||
streetNumber: 86, | ||
streetType: 'CHEMIN' | ||
} | ||
} | ||
], | ||
email: ' [email protected] ', | ||
name: { | ||
firstName: 'Chris', | ||
fullName: 'Chris A', | ||
lastName: 'A' | ||
}, | ||
phoneNumber: [ | ||
{ | ||
number: ' 060606060606', | ||
type: 'mobile' | ||
} | ||
] | ||
} | ||
|
||
const expectedContact = { | ||
address: [ | ||
{ | ||
city: 'CITY', | ||
formattedAddress: '86 CHEMIN DES DAMES 01001 CITY', | ||
postCode: '01001', | ||
street: { | ||
streetName: 'DES DAMES', | ||
streetNumber: 86, | ||
streetType: 'CHEMIN' | ||
} | ||
} | ||
], | ||
email: '[email protected]', | ||
name: { | ||
firstName: 'Chris', | ||
fullName: 'Chris A', | ||
lastName: 'A' | ||
}, | ||
phoneNumber: [ | ||
{ | ||
number: '060606060606', | ||
type: 'mobile' | ||
} | ||
] | ||
} | ||
|
||
expect(trimProperties(contact)).toEqual(expectedContact) | ||
}) | ||
}) |