-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- restored htmlBeautifier func-ty - reworked langs it render - added async flag to force calling .apply with cb on engine - added safer call of i18n - fixed lang bugs
- Loading branch information
Alexej Yaroshevich
committed
Feb 13, 2015
1 parent
d23bdb4
commit afa758a
Showing
7 changed files
with
107 additions
and
60 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,50 @@ | ||
it('should be equal `${ it }` by ${ engine.name }', function (<% if (saveHtml) { %>done<% } %>) { | ||
var bemjson = references['${ it }'].bemjson, | ||
expected = references['${ it }'].html, | ||
actual = engines['${ engine.name }'].apply(bemjson); | ||
<% | ||
// prepares | ||
var titleSuffix = lang ? ' in `' + lang + '` lang' : ''; | ||
var subreference = lang ? '[\'' + lang + '\']' : ''; | ||
var prettifyEngineName = function (ngn) { | ||
return lang ? String(ngn).toLowerCase().replace(' ', '-') + '.' + lang : ngn; | ||
}; | ||
if (saveHtml) { | ||
var filename = [it, prettifyEngineName(engine.name), 'html'].join('.'); | ||
} | ||
%> | ||
it('should be equal `${ it }` by ${ engine.name }${ titleSuffix }', function (<% if (saveHtml || engine.async) { %>done<% } %>) { | ||
var bemjson = references['${ it }']${ subreference }.bemjson, | ||
expected = references['${ it }']${ subreference }.html;<% | ||
if (lang) { %> | ||
lazies['${ engine.name }${ lang }'](); | ||
<% } | ||
if (!engine.async) { %> | ||
// sync mode | ||
var actual = engines['${ engine.name }']${ subreference }.apply(bemjson); | ||
assertHtml(actual, expected);<% | ||
if (saveHtml) { | ||
var filename = [it, engine.name, 'html'].join('.'), | ||
sep = '\n '; | ||
print(sep + 'fs.writeFile(path.join(__dirname, \'' + filename + '\'), beautifyHtml(actual), done);'); | ||
} %> | ||
if (saveHtml) { %> | ||
saveHtmlFile('${ filename }', actual, done); | ||
<% } | ||
} else { // engine.async %> | ||
// async mode | ||
engines['${ engine.name }']${ subreference }.apply(bemjson, function(errs, actual) { | ||
if (errs !== null) { | ||
done(errs); | ||
return; | ||
} | ||
assertHtml(actual, expected, function(err) { | ||
<% if (saveHtml) {%> | ||
saveHtmlFile('${ filename }', actual, function() { | ||
done(err || null); | ||
}); | ||
<% } else { %> | ||
done(err || null); | ||
<% } %> | ||
}); | ||
});<% | ||
} %> | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters