diff options
Diffstat (limited to 'services/sync/tests/unit/test_addons_validator.js')
-rw-r--r-- | services/sync/tests/unit/test_addons_validator.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/services/sync/tests/unit/test_addons_validator.js b/services/sync/tests/unit/test_addons_validator.js new file mode 100644 index 0000000000..069f15ef3b --- /dev/null +++ b/services/sync/tests/unit/test_addons_validator.js @@ -0,0 +1,69 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +const { AddonValidator } = ChromeUtils.import( + "resource://services-sync/engines/addons.js" +); + +function getDummyServerAndClient() { + return { + server: [ + { + id: "1111", + applicationID: Services.appinfo.ID, + addonID: "synced-addon@example.com", + enabled: true, + source: "amo", + understood: true, + }, + ], + client: [ + { + syncGUID: "1111", + id: "synced-addon@example.com", + type: "extension", + isSystem: false, + isSyncable: true, + }, + { + syncGUID: "2222", + id: "system-addon@example.com", + type: "extension", + isSystem: true, + isSyncable: false, + }, + { + // Plugins don't have a `syncedGUID`, but we don't sync them, so we + // shouldn't report them as client duplicates. + id: "some-plugin", + type: "plugin", + }, + { + id: "another-plugin", + type: "plugin", + }, + ], + }; +} + +add_task(async function test_valid() { + let { server, client } = getDummyServerAndClient(); + let validator = new AddonValidator({ + _findDupe(item) { + return null; + }, + isAddonSyncable(item) { + return item.type != "plugin"; + }, + }); + let { + problemData, + clientRecords, + records, + deletedRecords, + } = await validator.compareClientWithServer(client, server); + equal(clientRecords.length, 4); + equal(records.length, 1); + equal(deletedRecords.length, 0); + deepEqual(problemData, validator.emptyProblemData()); +}); |