v1.18.x
Barış Soner Uşaklı 5 years ago committed by GitHub
parent 4093c98794
commit ca3be1f336
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -541,7 +541,10 @@
} }
if (!(typeof text === 'string' || text instanceof String) || text === '') { if (!(typeof text === 'string' || text instanceof String) || text === '') {
return cb(''); if (cb) {
return setTimeout(cb, 0, '');
}
return '';
} }
return Translator.create(lang).translate(text).then(function (output) { return Translator.create(lang).translate(text).then(function (output) {

@ -21,6 +21,18 @@ describe('Translator shim', function () {
done(); done();
}); });
}); });
it('should translate empty string properly', function (done) {
shim.translate('', 'en-GB', function (translated) {
assert.strictEqual(translated, '');
done();
});
});
it('should translate empty string properly', async function () {
const translated = await shim.translate('', 'en-GB');
assert.strictEqual(translated, '');
});
}); });
}); });

Loading…
Cancel
Save