summaryrefslogtreecommitdiffstats
path: root/services/sync/tests/unit/test_addons_validator.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /services/sync/tests/unit/test_addons_validator.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'services/sync/tests/unit/test_addons_validator.js')
-rw-r--r--services/sync/tests/unit/test_addons_validator.js65
1 files changed, 65 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..60f2f8bf43
--- /dev/null
+++ b/services/sync/tests/unit/test_addons_validator.js
@@ -0,0 +1,65 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+const { AddonValidator } = ChromeUtils.importESModule(
+ "resource://services-sync/engines/addons.sys.mjs"
+);
+
+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());
+});