Parse phone numbers into e164 as part of schema upgrade
This commit is contained in:
parent
8cb1f1f532
commit
aa13a2c6f7
8 changed files with 87 additions and 8 deletions
|
@ -36,6 +36,46 @@ describe('Contact', () => {
|
|||
assert.deepEqual(result, message.contact[0]);
|
||||
});
|
||||
|
||||
it('turns phone numbers to e164 format', async () => {
|
||||
const upgradeAttachment = sinon
|
||||
.stub()
|
||||
.throws(new Error("Shouldn't be called"));
|
||||
const upgradeVersion = Contact.parseAndWriteAvatar(upgradeAttachment);
|
||||
|
||||
const message = {
|
||||
body: 'hey there!',
|
||||
contact: [
|
||||
{
|
||||
name: {
|
||||
displayName: 'Someone Somewhere',
|
||||
},
|
||||
number: [
|
||||
{
|
||||
type: 1,
|
||||
value: '(202) 555-0099',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
const expected = {
|
||||
name: {
|
||||
displayName: 'Someone Somewhere',
|
||||
},
|
||||
number: [
|
||||
{
|
||||
type: 1,
|
||||
value: '+12025550099',
|
||||
},
|
||||
],
|
||||
};
|
||||
const result = await upgradeVersion(message.contact[0], {
|
||||
message,
|
||||
regionCode: 'US',
|
||||
});
|
||||
assert.deepEqual(result, expected);
|
||||
});
|
||||
|
||||
it('removes contact avatar if it has no sub-avatar', async () => {
|
||||
const upgradeAttachment = sinon
|
||||
.stub()
|
||||
|
|
|
@ -277,6 +277,7 @@ describe('Message', () => {
|
|||
assert.deepEqual(attachmentData, expectedAttachmentData);
|
||||
return 'abc/abcdefg';
|
||||
},
|
||||
getRegionCode: () => 'US',
|
||||
};
|
||||
const actual = await Message.upgradeSchema(input, context);
|
||||
assert.deepEqual(actual, expected);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue