Skip to content

Commit bcd7dbb

Browse files
committed
Filter out some tests on Node.js < 20
1 parent 89588f2 commit bcd7dbb

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

fluent-langneg/test/langneg_test.js

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import assert from "assert";
22
import { negotiateLanguages } from "../esm/negotiate_languages.js";
33

4+
const nodeVersion = parseInt(process.version.substring(1));
5+
46
const data = {
57
filtering: {
68
"exact match": [
@@ -42,7 +44,14 @@ const data = {
4244
],
4345
[["fr"], ["fr-CA", "fr-FR"], ["fr-FR", "fr-CA"]],
4446
[["az-IR"], ["az-Latn", "az-Arab"], ["az-Arab"]],
45-
[["sr-RU"], ["sr-Cyrl", "sr-Latn"], ["sr-Cyrl"]],
47+
[
48+
["sr-RU"],
49+
["sr-Cyrl", "sr-Latn"],
50+
["sr-Cyrl"],
51+
undefined,
52+
undefined,
53+
20,
54+
],
4655
[["sr"], ["sr-Latn", "sr-Cyrl"], ["sr-Cyrl"]],
4756
[["zh-GB"], ["zh-Hans", "zh-Hant"], ["zh-Hant"]],
4857
[["sr", "ru"], ["sr-Latn", "ru"], ["ru"]],
@@ -82,13 +91,13 @@ const data = {
8291
],
8392
"should handle default locale properly": [
8493
[["fr"], ["de", "it"], []],
85-
[["fr"], ["de", "it"], "en-US", ["en-US"]],
86-
[["fr"], ["de", "en-US"], "en-US", ["en-US"]],
94+
[["fr"], ["de", "it"], ["en-US"], "en-US"],
95+
[["fr"], ["de", "en-US"], ["en-US"], "en-US"],
8796
[
8897
["fr", "de-DE"],
8998
["de-DE", "fr-CA"],
90-
"en-US",
9199
["fr-CA", "de-DE", "en-US"],
100+
"en-US",
92101
],
93102
],
94103
"should handle all matches on the 1st higher than any on the 2nd": [
@@ -126,21 +135,21 @@ const data = {
126135
[
127136
["fr", "en"],
128137
["en-US", "fr-FR", "en", "fr"],
138+
["fr", "en"],
129139
undefined,
130140
"matching",
131-
["fr", "en"],
132141
],
133-
[["es-419"], ["es", "en"], undefined, "matching", ["es"]],
142+
[["es-419"], ["es", "en"], ["es"], undefined, "matching"],
134143
],
135144
},
136145
lookup: {
137146
"should match only one": [
138147
[
139148
["fr-FR", "en"],
140149
["en-US", "fr-FR", "en", "fr"],
150+
["fr-FR"],
141151
"en-US",
142152
"lookup",
143-
["fr-FR"],
144153
],
145154
],
146155
},
@@ -154,14 +163,18 @@ suite("Language Negotiation", () => {
154163
const group = data[strategy][groupName];
155164

156165
test(`${strategy} - ${groupName}`, () => {
157-
for (const test of group) {
158-
const requested = test[0];
159-
const available = test[1];
160-
const supported = test[test.length - 1];
161-
162-
const result = negotiateLanguages(test[0], test[1], {
163-
defaultLocale: test.length > 3 ? test[2] : undefined,
164-
strategy: test.length > 4 ? test[3] : undefined,
166+
for (const [
167+
requested,
168+
available,
169+
supported,
170+
defaultLocale,
171+
strategy,
172+
minNodeVersion,
173+
] of group) {
174+
if (nodeVersion < minNodeVersion) return;
175+
const result = negotiateLanguages(requested, available, {
176+
defaultLocale,
177+
strategy,
165178
});
166179
assert.deepEqual(
167180
result,

0 commit comments

Comments
 (0)