This commit is contained in:
Barış Soner Uşaklı
2019-10-16 13:33:00 -04:00
committed by GitHub
parent 4093c98794
commit ca3be1f336
2 changed files with 16 additions and 1 deletions

View File

@@ -541,7 +541,10 @@
}
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) {

View File

@@ -21,6 +21,18 @@ describe('Translator shim', function () {
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, '');
});
});
});