Skip to content

Commit

Permalink
Implement code refactoring in tests for i18n-bemjson-to-html accordin…
Browse files Browse the repository at this point in the history
…g to blond notations
  • Loading branch information
tormozz48 committed May 25, 2015
1 parent 8b6146a commit 03b0903
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions test/techs/i18n-bemjson-to-html.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('i18n-bemjson-to-html', function () {
});

describe('must generate html with i18n', function () {
function testForTemplate(template) {
function testForTemplate(template, templateName) {
var scheme = {
blocks: {},
bundle: {
Expand All @@ -31,32 +31,39 @@ describe('i18n-bemjson-to-html', function () {
}
};

scheme.bundle['bundle.' + template + '.js'] = {
bemhtml: 'exports.BEMHTML.apply',
bh: 'exports.apply'
}[template] + ' = function(bemjson) { return "<html>" + BEM.I18N() + "</html>"; };';
scheme.bundle['bundle.' + (templateName || 'template') + '.js'] = template;

mock(scheme);

bundle = new TestNode('bundle');

return bundle.runTechAndGetContent(
Tech, { templateFile: '?.' + template + '.js', lang: 'ru' }
Tech, { templateFile: '?.' + (templateName || 'template') + '.js', lang: 'ru' }
).spread(function (html) {
return html.toString();
});
}

it('must generate valid html for bemhtml template', function () {
testForTemplate('bemhtml').then(function (html) {
html.must.be('<html>i18n-key</html>');
});
testForTemplate('exports.BEMHTML.apply = function(bemjson) { return "<html>" + BEM.I18N() + "</html>"; };')
.then(function (html) {
html.must.be('<html>i18n-key</html>');
});
});

it('must generate valid html for bh template', function () {
testForTemplate('bh').then(function (html) {
html.must.be('<html>i18n-key</html>');
});
testForTemplate('exports.apply = function(bemjson) { return "<html>" + BEM.I18N() + "</html>"; };')
.then(function (html) {
html.must.be('<html>i18n-key</html>');
});
});

it('must use valid template file', function () {
var template = 'exports.apply = function(bemjson) { return "<html>" + BEM.I18N() + "</html>"; };';
testForTemplate(template, 'bh')
.then(function (html) {
html.must.be('<html>i18n-key</html>');
});
});
});

Expand Down

0 comments on commit 03b0903

Please sign in to comment.