Skip to content

Commit 1ad50d5

Browse files
committed
add tests
1 parent ef3aeac commit 1ad50d5

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

test/techs/bh-client-module.test.js

+20
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,26 @@ describe('bh-client-module', function () {
7171
return runTest(test, options);
7272
});
7373

74+
it('mimic to different template engines', function () {
75+
var test = [
76+
'chai.should();',
77+
'describe("bh-client-module", function () {',
78+
'it("autogenerated test", function (done) {',
79+
'modules.require(["BEMHTML", "render"], function (BEMHTML, render) {',
80+
'BEMHTML.apply({ block: "block" }).should.equal(\'<a class="block"></a>\');',
81+
'render.apply({ block: "block" }).should.equal(\'<a class="block"></a>\');',
82+
'done();',
83+
'});',
84+
'});',
85+
'});'
86+
].join('\n'),
87+
options = {
88+
mimic: ['BEMHTML', 'render']
89+
};
90+
91+
return runTest(test, options);
92+
});
93+
7494
describe('jsAttr', function () {
7595
it('should use dafault jsAttrName and jsAttrScheme params', function () {
7696
var test = generateTest(

test/techs/bh-server.test.js

+19
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,22 @@ describe('bh-server', function () {
8383
return assert(bemjson, html, templates);
8484
});
8585

86+
it('mimic to BEMHTML', function () {
87+
var templates = [
88+
[
89+
'bh.match("block", function(ctx) {',
90+
'var url = require("url");',
91+
'ctx.content(url.resolve("http://example.com/", "/pathname"));',
92+
'});'
93+
].join('\n')
94+
],
95+
bemjson = { block: 'block' },
96+
html = '<div class="block">http://example.com/pathname</div>',
97+
options = { mimic: ['BH', 'BEMHTML'] };
98+
99+
return assert(bemjson, html, templates, options);
100+
});
101+
86102
it('must correctly resolve path', function () {
87103
var template = [
88104
'bh.match("block", function(ctx) {',
@@ -263,5 +279,8 @@ function assert(bemjson, html, templates, options) {
263279
return bundle.runTechAndRequire(bhServer, options)
264280
.spread(function (bh) {
265281
bh.apply(bemjson).must.be(html);
282+
options && options.mimic && options.mimic.forEach(function (name) {
283+
bh[name].apply(bemjson).must.be(html);
284+
});
266285
});
267286
}

0 commit comments

Comments
 (0)