2020-03-19 14:07:20 +00:00
|
|
|
const should = require('should');
|
|
|
|
const path = require('path');
|
2020-03-30 16:26:47 +01:00
|
|
|
const settingsCache = require('../../../core/server/services/settings/cache');
|
|
|
|
const helpers = require('../../../core/frontend/helpers');
|
|
|
|
const themeI18n = require('../../../core/frontend/services/themes/i18n');
|
2020-03-19 14:07:20 +00:00
|
|
|
const configUtils = require('../../utils/configUtils');
|
2018-01-09 14:50:57 +01:00
|
|
|
|
|
|
|
describe('{{t}} helper', function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
settingsCache.set('active_theme', {value: 'casper'});
|
|
|
|
configUtils.set('paths:contentPath', path.join(__dirname, '../../utils/fixtures/'));
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
|
|
|
settingsCache.shutdown();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('theme translation is DE', function () {
|
2020-06-22 22:27:05 +12:00
|
|
|
settingsCache.set('lang', {value: 'de'});
|
2020-03-19 14:07:20 +00:00
|
|
|
themeI18n.init();
|
2018-01-09 14:50:57 +01:00
|
|
|
|
|
|
|
let rendered = helpers.t.call({}, 'Top left Button', {
|
|
|
|
hash: {}
|
|
|
|
});
|
|
|
|
|
|
|
|
rendered.should.eql('Oben Links.');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('theme translation is EN', function () {
|
2020-06-22 22:27:05 +12:00
|
|
|
settingsCache.set('lang', {value: 'en'});
|
2020-03-19 14:07:20 +00:00
|
|
|
themeI18n.init();
|
2018-01-09 14:50:57 +01:00
|
|
|
|
|
|
|
let rendered = helpers.t.call({}, 'Top left Button', {
|
|
|
|
hash: {}
|
|
|
|
});
|
|
|
|
|
|
|
|
rendered.should.eql('Left Button on Top');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('[fallback] no theme translation file found for FR', function () {
|
2020-06-22 22:27:05 +12:00
|
|
|
settingsCache.set('lang', {value: 'fr'});
|
2020-03-19 14:07:20 +00:00
|
|
|
themeI18n.init();
|
2018-01-09 14:50:57 +01:00
|
|
|
|
|
|
|
let rendered = helpers.t.call({}, 'Top left Button', {
|
|
|
|
hash: {}
|
|
|
|
});
|
|
|
|
|
|
|
|
rendered.should.eql('Left Button on Top');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('[fallback] no theme files at all, use key as translation', function () {
|
|
|
|
settingsCache.set('active_theme', {value: 'casper-1.4'});
|
2020-06-22 22:27:05 +12:00
|
|
|
settingsCache.set('lang', {value: 'de'});
|
2020-03-19 14:07:20 +00:00
|
|
|
themeI18n.init();
|
2018-01-09 14:50:57 +01:00
|
|
|
|
|
|
|
let rendered = helpers.t.call({}, 'Top left Button', {
|
|
|
|
hash: {}
|
|
|
|
});
|
|
|
|
|
|
|
|
rendered.should.eql('Top left Button');
|
|
|
|
});
|
|
|
|
});
|