-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(mespapiers):
makeContactFlexsearchProps
must handle string emails
On the connector side, the `email` field of the `Contact` object could be a string instead of an object array. Issue fixed here: konnectors/libs#987 Pending the propagation of the fix, it is relevant to predict the case here.
- Loading branch information
Showing
2 changed files
with
53 additions
and
2 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 |
---|---|---|
|
@@ -5,7 +5,8 @@ import { | |
makeFileTags, | ||
makeContactTags, | ||
makeFileFlexsearchProps, | ||
makeMultipleSearchResultIds | ||
makeMultipleSearchResultIds, | ||
makeContactFlexsearchProps | ||
} from './helpers' | ||
import { index } from './search' | ||
|
||
|
@@ -18,6 +19,48 @@ jest.mock('./search', () => ({ | |
|
||
const mockT = x => x | ||
|
||
describe('makeContactFlexsearchProps', () => { | ||
const expectedResult = { | ||
'address[0].formattedAddress': '2 place Victor Hugo', | ||
'email[0].address': '[email protected]', | ||
'phone[0].number': '0123456789', | ||
tag: ['identity', 'home', 'work_study'], | ||
translated: { | ||
address: 'Search.attributeLabel.address', | ||
email: 'Search.attributeLabel.email', | ||
phone: 'Search.attributeLabel.phone' | ||
} | ||
} | ||
it('should return correct formatted contact for flexsearch', () => { | ||
const res = makeContactFlexsearchProps( | ||
{ | ||
name: { givenName: 'Victor', familyName: 'Hugo' }, | ||
email: [{ address: '[email protected]' }], | ||
phone: [{ number: '0123456789' }], | ||
company: 'Cozy', | ||
address: [{ formattedAddress: '2 place Victor Hugo' }] | ||
}, | ||
mockT | ||
) | ||
|
||
expect(res).toStrictEqual(expectedResult) | ||
}) | ||
it('should return correct formatted contact for flexsearch when email is a String', () => { | ||
const res = makeContactFlexsearchProps( | ||
{ | ||
name: { givenName: 'Victor', familyName: 'Hugo' }, | ||
email: '[email protected]', | ||
phone: [{ number: '0123456789' }], | ||
company: 'Cozy', | ||
address: [{ formattedAddress: '2 place Victor Hugo' }] | ||
}, | ||
mockT | ||
) | ||
|
||
expect(res).toStrictEqual(expectedResult) | ||
}) | ||
}) | ||
|
||
describe('makeRealtimeConnection', () => { | ||
it('should return a well structured object', () => { | ||
const res = makeRealtimeConnection( | ||
|