2020-03-19 17:07:20 +03:00
|
|
|
const should = require('should');
|
|
|
|
const path = require('path');
|
2020-03-30 18:26:47 +03:00
|
|
|
const helpers = require('../../../core/frontend/helpers');
|
2021-04-26 13:53:15 +03:00
|
|
|
const themeI18n = require('../../../core/frontend/services/theme-engine/i18n');
|
2018-01-09 16:50:57 +03:00
|
|
|
|
|
|
|
describe('{{t}} helper', function () {
|
2021-05-06 12:38:56 +03:00
|
|
|
let ogBasePath = themeI18n.basePath;
|
|
|
|
|
|
|
|
before(function () {
|
|
|
|
themeI18n.basePath = path.join(__dirname, '../../utils/fixtures/themes/');
|
2018-01-09 16:50:57 +03:00
|
|
|
});
|
|
|
|
|
2021-05-06 12:38:56 +03:00
|
|
|
after(function () {
|
|
|
|
themeI18n.basePath = ogBasePath;
|
2018-01-09 16:50:57 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('theme translation is DE', function () {
|
2021-05-04 18:49:35 +03:00
|
|
|
themeI18n.init({activeTheme: 'casper', locale: 'de'});
|
2018-01-09 16:50:57 +03:00
|
|
|
|
|
|
|
let rendered = helpers.t.call({}, 'Top left Button', {
|
|
|
|
hash: {}
|
|
|
|
});
|
|
|
|
|
|
|
|
rendered.should.eql('Oben Links.');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('theme translation is EN', function () {
|
2021-05-04 18:49:35 +03:00
|
|
|
themeI18n.init({activeTheme: 'casper', locale: 'en'});
|
2018-01-09 16:50:57 +03: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 () {
|
2021-05-04 18:49:35 +03:00
|
|
|
themeI18n.init({activeTheme: 'casper', locale: 'fr'});
|
2018-01-09 16:50:57 +03: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 () {
|
2021-05-04 18:49:35 +03:00
|
|
|
themeI18n.init({activeTheme: 'casper-1.4', locale: 'de'});
|
2018-01-09 16:50:57 +03:00
|
|
|
|
|
|
|
let rendered = helpers.t.call({}, 'Top left Button', {
|
|
|
|
hash: {}
|
|
|
|
});
|
|
|
|
|
|
|
|
rendered.should.eql('Top left Button');
|
|
|
|
});
|
|
|
|
});
|