summaryrefslogtreecommitdiffstats
path: root/intl/l10n/test/test_messagecontext.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /intl/l10n/test/test_messagecontext.js
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'intl/l10n/test/test_messagecontext.js')
-rw-r--r--intl/l10n/test/test_messagecontext.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/intl/l10n/test/test_messagecontext.js b/intl/l10n/test/test_messagecontext.js
new file mode 100644
index 0000000000..7ab17dea90
--- /dev/null
+++ b/intl/l10n/test/test_messagecontext.js
@@ -0,0 +1,47 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function run_test() {
+ test_methods_presence(FluentBundle);
+ test_methods_calling(FluentBundle, FluentResource);
+ test_number_options(FluentBundle, FluentResource);
+
+ ok(true);
+}
+
+function test_methods_presence(FluentBundle) {
+ const bundle = new FluentBundle(["en-US", "pl"]);
+ equal(typeof bundle.addResource, "function");
+ equal(typeof bundle.formatPattern, "function");
+}
+
+function test_methods_calling(FluentBundle, FluentResource) {
+ const bundle = new FluentBundle(["en-US", "pl"], {
+ useIsolating: false,
+ });
+ bundle.addResource(new FluentResource("key = Value"));
+
+ const msg = bundle.getMessage("key");
+ equal(bundle.formatPattern(msg.value), "Value");
+
+ bundle.addResource(new FluentResource("key2 = Hello { $name }"));
+
+ const msg2 = bundle.getMessage("key2");
+ equal(bundle.formatPattern(msg2.value, { name: "Amy" }), "Hello Amy");
+ ok(true);
+}
+
+function test_number_options(FluentBundle, FluentResource) {
+ const bundle = new FluentBundle(["en-US", "pl"], {
+ useIsolating: false,
+ });
+ bundle.addResource(new FluentResource(`
+key = { NUMBER(0.53, style: "percent") } { NUMBER(0.12, style: "percent", minimumFractionDigits: 0) }
+ { NUMBER(-2.5, style: "percent") } { NUMBER(2.91, style: "percent") } { NUMBER("wrong", style: "percent") }
+`));
+
+ const msg = bundle.getMessage("key");
+ equal(bundle.formatPattern(msg.value), "53.00% 12%\n-250.0% 291.00% ");
+
+ ok(true);
+}