Skip to content

Commit 8261923

Browse files
test(mf2): Fix mf2-features test suite
1 parent 86bf773 commit 8261923

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

mf2/messageformat/src/mf2-features.test.mts renamed to mf2/messageformat/src/mf2-features.test.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('Plural Range Selectors & Range Formatters (unicode-org/message-format-
2929
const value = `${start} - ${end}`;
3030
return {
3131
type: 'range',
32-
locale,
32+
dir: 'ltr',
3333
source,
3434
selectKey(keys) {
3535
if (locale !== 'nl') throw new Error('Only Dutch supported');
@@ -147,7 +147,9 @@ describe('Multi-selector messages (unicode-org/message-format-wg#119)', () => {
147147
AREA: String(undefined),
148148
Q: String(undefined)
149149
});
150-
expect(one.replace(/\s+/g, ' ').trim()).toBe('Listing one foo item');
150+
expect(one.replace(/\s+/g, ' ').trim()).toBe(
151+
'Listing one \u2068foo\u2069 item'
152+
);
151153

152154
const two = mf.format({
153155
N: 2,
@@ -159,7 +161,7 @@ describe('Multi-selector messages (unicode-org/message-format-wg#119)', () => {
159161
Q: '"bar"'
160162
});
161163
expect(two.replace(/\s+/g, ' ').trim()).toBe(
162-
'Listing 2 current and future foo items in there matching the query "bar"'
164+
'Listing 2 current and future \u2068foo\u2069 items in \u2068there\u2069 matching the query \u2068"bar"\u2069'
163165
);
164166
});
165167

@@ -227,7 +229,7 @@ maybe('List formatting', () => {
227229
return {
228230
type: 'list',
229231
source,
230-
locale: lf.resolvedOptions().locale,
232+
dir: 'ltr',
231233
toParts: () =>
232234
lf.formatToParts(list).map(part => Object.assign(part, { source })),
233235
toString: () => lf.format(list)
@@ -325,14 +327,20 @@ describe('Neighbouring text transformations (unicode-org/message-format-wg#160)'
325327
hackyFixArticles(['en'], parts);
326328
expect(parts).toEqual([
327329
{ type: 'literal', value: 'A ' },
330+
{ type: 'bidiIsolation', value: '\u2068' },
328331
{ type: 'string', locale: 'en', source: '$foo', value: 'foo' },
332+
{ type: 'bidiIsolation', value: '\u2069' },
329333
{ type: 'literal', value: ' and an ' },
330-
{ type: 'string', locale: 'en', source: '$other', value: 'other' }
334+
{ type: 'bidiIsolation', value: '\u2068' },
335+
{ type: 'string', locale: 'en', source: '$other', value: 'other' },
336+
{ type: 'bidiIsolation', value: '\u2069' }
331337
]);
332338
});
333339

334340
test('Match, changed', () => {
335-
const mf = new MessageFormat('en', 'A {$foo} and an {$other}');
341+
const mf = new MessageFormat('en', 'A {$foo} and an {$other}', {
342+
bidiIsolation: 'none'
343+
});
336344
const parts = mf.formatToParts({ foo: 'other', other: 'foo' });
337345
hackyFixArticles(['en'], parts);
338346
expect(parts).toEqual([
@@ -344,7 +352,9 @@ describe('Neighbouring text transformations (unicode-org/message-format-wg#160)'
344352
});
345353

346354
test('No match, no change', () => {
347-
const mf = new MessageFormat('en', 'The {$foo} and lotsa {$other}');
355+
const mf = new MessageFormat('en', 'The {$foo} and lotsa {$other}', {
356+
bidiIsolation: 'none'
357+
});
348358
const parts = mf.formatToParts({ foo: 'foo', other: 'other' });
349359
hackyFixArticles(['en'], parts);
350360
expect(parts).toEqual([
@@ -356,7 +366,9 @@ describe('Neighbouring text transformations (unicode-org/message-format-wg#160)'
356366
});
357367

358368
test('Articles across non-wordy content', () => {
359-
const mf = new MessageFormat('en', '{$foo} foo and a {|...|} {$other}');
369+
const mf = new MessageFormat('en', '{$foo} foo and a {|...|} {$other}', {
370+
bidiIsolation: 'none'
371+
});
360372
const parts = mf.formatToParts({ foo: 'An', other: 'other' });
361373
hackyFixArticles(['en'], parts);
362374
expect(parts).toEqual([

0 commit comments

Comments
 (0)