summaryrefslogtreecommitdiffstats
path: root/toolkit/components/translations/tests/browser/browser_translations_actor_versioning.js
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/translations/tests/browser/browser_translations_actor_versioning.js')
-rw-r--r--toolkit/components/translations/tests/browser/browser_translations_actor_versioning.js81
1 files changed, 81 insertions, 0 deletions
diff --git a/toolkit/components/translations/tests/browser/browser_translations_actor_versioning.js b/toolkit/components/translations/tests/browser/browser_translations_actor_versioning.js
new file mode 100644
index 0000000000..7e96f62fbf
--- /dev/null
+++ b/toolkit/components/translations/tests/browser/browser_translations_actor_versioning.js
@@ -0,0 +1,81 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+add_task(async function test_remote_settings_versioning() {
+ const tests = [
+ {
+ majorVersion: 1,
+ existingVersion: "1.0",
+ nextVersion: "1.1",
+ expectation: true,
+ },
+ {
+ majorVersion: 1,
+ existingVersion: null,
+ nextVersion: "1.1",
+ expectation: true,
+ },
+ {
+ majorVersion: 1,
+ existingVersion: null,
+ nextVersion: "1.0beta",
+ expectation: true,
+ },
+ {
+ majorVersion: 1,
+ existingVersion: null,
+ nextVersion: "1.0a",
+ expectation: true,
+ },
+ {
+ majorVersion: 2,
+ existingVersion: null,
+ nextVersion: "1.0a",
+ expectation: false,
+ },
+ {
+ majorVersion: 2,
+ existingVersion: "2.0",
+ nextVersion: "1.0a",
+ expectation: false,
+ },
+ {
+ majorVersion: 2,
+ existingVersion: "2.1",
+ nextVersion: "3.2",
+ expectation: false,
+ },
+ {
+ majorVersion: 2,
+ existingVersion: null,
+ nextVersion: "3.2",
+ expectation: false,
+ },
+ {
+ majorVersion: 1,
+ nextVersion: "1.0",
+ existingVersion: undefined,
+ expectation: true,
+ },
+ ];
+ for (const {
+ majorVersion,
+ existingVersion,
+ nextVersion,
+ expectation,
+ } of tests) {
+ is(
+ TranslationsParent.isBetterRecordVersion(
+ majorVersion,
+ nextVersion,
+ existingVersion
+ ),
+ expectation,
+ `Given a major version of ${majorVersion}, an existing version ${existingVersion} ` +
+ `and a next version of ${nextVersion}, is the next version is ` +
+ `${expectation ? "" : "not "}best.`
+ );
+ }
+});