Skip to content

Commit a65385a

Browse files
committed
Workaround Node.js bug causing test to fail
1 parent 465e850 commit a65385a

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

test/moTest.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,20 @@ describe('mo', function(){
198198
plural_forms: 'nplurals=4; plural=(n==1) ? 0 : (n%10==1 && n%100!=11) ? 3 : ((n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20)) ? 1 : 2);'
199199
});
200200

201-
/* String gets mangled because it's the wrong encoding. */
202-
locale_data.messages.should.have.property('Manage Comments', [
203-
'Управление комментариями'
204-
]);
201+
locale_data.messages.should.have.property('Manage Comments');
202+
locale_data.messages['Manage Comments'].should.have.length(1);
203+
204+
var message = locale_data.messages['Manage Comments'][0];
205+
206+
if (typeof Buffer !== 'undefined') {
207+
/* There's a bug in Node.js's implementation of TextDecoder that causes it to
208+
incorrectly decode several Windows-1252 characters, see
209+
<https://github.com/nodejs/node/issues/56542>. */
210+
Buffer.from(message, 'utf8').toString('base64').should.equal('w5DCo8OQwr/DkcKAw5DCsMOQwrLDkMK7w5DCtcOQwr3DkMK4w5DCtSDDkMK6w5DCvsOQwrzDkMK8w5DCtcOQwr3DkcKCw5DCsMORwoDDkMK4w5HCj8OQwrzDkMK4');
211+
} else {
212+
/* UTF-8 string read using the Windows-1252 encoding. */
213+
message.should.equal('Управление комментариями');
214+
}
205215
})
206216
it('should throw for an invalid encoding option', function(){
207217
(function(){

0 commit comments

Comments
 (0)