Skip to content

Commit

Permalink
test: Trashed contact with no resource name
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricmessiant committed Mar 1, 2019
1 parent f54a117 commit 7107084
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
39 changes: 39 additions & 0 deletions src/__snapshots__/synchronizeContacts.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,45 @@ Array [
]
`;

exports[`synchronizeContacts function should synchronize contacts: destroyRodTrompInCozy 1`] = `
Array [
Object {
"_rev": "af1cd883-216b-42eb-9766-d54ebed38658",
"_type": "io.cozy.contacts",
"address": Array [],
"birthday": null,
"company": null,
"cozyMetadata": Object {
"createdAt": "2018-04-22T17:33:00.123Z",
"createdByApp": "Contacts",
"createdByAppVersion": "2.0.0",
"doctypeVersion": 2,
"sourceAccount": "45c49c15-4b00-48e8-8bfd-29f8177b89ff",
"updatedAt": "2018-12-22T15:18:00.222Z",
"updatedByApps": Array [
"Contacts",
"konnector-google",
],
},
"email": Array [],
"id": "deleted-on-cozy-no-resource-name",
"metadata": Object {
"google": Object {
"metadata": null,
},
"version": 1,
},
"name": Object {
"familyName": "Tromp",
"givenName": "Rod",
},
"note": null,
"phone": Array [],
"trashed": true,
},
]
`;

exports[`synchronizeContacts function should synchronize contacts: fabiolaGrozdanaInGoogle 1`] = `
Array [
"people/924609",
Expand Down
24 changes: 22 additions & 2 deletions src/synchronizeContacts.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,22 @@ const cozyContacts = [
}
}
}
},
{
id: 'deleted-on-cozy-no-resource-name',
_type: 'io.cozy.contacts',
_rev: 'af1cd883-216b-42eb-9766-d54ebed38658',
trashed: true,
name: { givenName: 'Rod', familyName: 'Tromp' },
cozyMetadata: {
doctypeVersion: 2,
createdAt: '2018-04-22T17:33:00.123Z',
createdByApp: 'Contacts',
createdByAppVersion: '2.0.0',
updatedAt: '2018-12-22T15:18:00.222Z',
updatedByApps: ['Contacts', 'konnector-google'],
sourceAccount: SOURCE_ACCOUNT_ID
}
}
]

Expand Down Expand Up @@ -344,7 +360,7 @@ describe('synchronizeContacts function', () => {
expect(result).toEqual({
cozy: {
created: 2,
deleted: 3,
deleted: 4,
updated: 2
},
google: {
Expand Down Expand Up @@ -378,7 +394,7 @@ describe('synchronizeContacts function', () => {
)
expect(fakeCozyClient.save.mock.calls[6]).toMatchSnapshot('johnDoeInCozy')

expect(fakeCozyClient.destroy).toHaveBeenCalledTimes(3)
expect(fakeCozyClient.destroy).toHaveBeenCalledTimes(4)

expect(fakeCozyClient.destroy.mock.calls[0]).toMatchSnapshot(
'destroyAureliaHayesInCozy'
Expand All @@ -389,6 +405,10 @@ describe('synchronizeContacts function', () => {
)

expect(fakeCozyClient.destroy.mock.calls[2]).toMatchSnapshot(
'destroyRodTrompInCozy'
)

expect(fakeCozyClient.destroy.mock.calls[3]).toMatchSnapshot(
'destroyFabiolaGrozdanaInCozy'
)

Expand Down

0 comments on commit 7107084

Please sign in to comment.