test: missing translator tests

This commit is contained in:
Barış Soner Uşaklı
2025-01-07 13:55:40 -05:00
parent 127e0e22cf
commit 0d3a8757bd
2 changed files with 36 additions and 0 deletions

View File

@@ -41,6 +41,36 @@ describe('Translator shim', () => {
assert.strictEqual(t, 'secret');
});
});
describe('translateKeys', () => {
it('should translate each key in array', async () => {
const translated = await shim.translateKeys(['[[global:home]]', '[[global:search]]'], 'en-GB');
assert.deepStrictEqual(translated, ['Home', 'Search']);
});
it('should translate each key in array using a callback', (done) => {
shim.translateKeys(['[[global:save]]', '[[global:close]]'], 'en-GB', (translated) => {
assert.deepStrictEqual(translated, ['Save', 'Close']);
done();
});
});
});
it('should load translations for language', (done) => {
shim.load('en-GB', 'global', (translations) => {
assert(translations);
assert(translations['header.profile']);
done();
});
});
it('should get translations for language', (done) => {
shim.getTranslations('en-GB', 'global', (translations) => {
assert(translations);
assert(translations['header.profile']);
done();
});
});
});
describe('new Translator(language)', () => {

View File

@@ -567,5 +567,11 @@ describe('Utility Methods', () => {
assert.strictEqual(el.find('#text').text(), 'Home');
assert.strictEqual(el.find('#search').attr('title'), 'Search');
});
it('should not error', (done) => {
shim.flush();
shim.flushNamespace();
done();
});
});
});