Skip to content

Commit

Permalink
Merge pull request #194 from enb-bem/issue-192
Browse files Browse the repository at this point in the history
Fixed bug with boolean mods for depsByTech
  • Loading branch information
blond committed Jan 22, 2016
2 parents 89b6dc2 + 13efbc2 commit 87a8347
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions techs/deps-by-tech-to-bemdecl.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ module.exports = inherit(BaseTech, {
if (dep[depType]) {
deps.flattenDeps(dep[depType]).forEach(function (singleDep) {
singleDep.block || (singleDep.block = notation.block);
singleDep.val || singleDep.mod && (singleDep.val = true);

if (!destTech || singleDep.tech === destTech) {
var key = depKey(singleDep);
Expand Down
39 changes: 39 additions & 0 deletions test/techs/deps-by-tech-to-bemdecl.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,23 @@ describe('techs: deps', function () {
return assert(scheme, bemdecl, exepted);
});

it('must add must dep of block boolean mod with short record', function () {
var scheme = {
blocks: {
block: {
'block.deps.js': stringifyDepsJs({
tech: 'sourceTech',
mustDeps: [{ block: 'other-block', mod: 'mod' }]
})
}
}
},
bemdecl = [{ name: 'block' }],
exepted = [{ name: 'other-block', mods: [{ name: 'mod', vals: [{ name: true }] }] }];

return assert(scheme, bemdecl, exepted);
});

it('must add must dep of block mod', function () {
var scheme = {
blocks: {
Expand Down Expand Up @@ -330,6 +347,28 @@ describe('techs: deps', function () {
return assert(scheme, bemdecl, exepted);
});

it('must add must dep of elem bool mod with short record', function () {
var scheme = {
blocks: {
block: {
'block.deps.js': stringifyDepsJs({
tech: 'sourceTech',
mustDeps: [
{ block: 'other-block', elem: 'elem', mod: 'mod' }
]
})
}
}
},
bemdecl = [{ name: 'block' }],
exepted = [{
name: 'other-block',
elems: [{ name: 'elem', mods: [{ name: 'mod', vals: [{ name: true }] }] }]
}];

return assert(scheme, bemdecl, exepted);
});

it('must add must dep of elem mod', function () {
var scheme = {
blocks: {
Expand Down

0 comments on commit 87a8347

Please sign in to comment.