Skip to content

Commit

Permalink
Fixed bug with context for depsByTech
Browse files Browse the repository at this point in the history
  • Loading branch information
blond committed Jan 22, 2016
1 parent 87a8347 commit e90de63
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 0 deletions.
3 changes: 3 additions & 0 deletions techs/deps-by-tech-to-bemdecl.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ module.exports = inherit(BaseTech, {
if (dep[depType]) {
deps.flattenDeps(dep[depType]).forEach(function (singleDep) {
singleDep.block || (singleDep.block = notation.block);
singleDep.elem || notation.elem && (singleDep.elem = notation.elem);
singleDep.mod || notation.modName && (singleDep.mod = notation.modName);
singleDep.val || notation.modVal && (singleDep.val = notation.modVal);
singleDep.val || singleDep.mod && (singleDep.val = true);

if (!destTech || singleDep.tech === destTech) {
Expand Down
136 changes: 136 additions & 0 deletions test/techs/deps-by-tech-to-bemdecl.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,142 @@ describe('techs: deps', function () {
});

describe('deps.js format', function () {
it('respect context for block', function () {
var scheme = {
blocks: {
block: {
'block.deps.js': stringifyDepsJs({
tech: 'sourceTech',
shouldDeps: {
tech: 'destTech',
}
})
}
}
},
bemdecl = [{ name: 'block' }],
exepted = [{ name: 'block' }];

return assert(scheme, bemdecl, exepted, { sourceTech: 'sourceTech', destTech: 'destTech' });
});

it('respect context for mod', function () {
var scheme = {
blocks: {
block: {
_mod: {
'block_mod_val.deps.js': stringifyDepsJs({
tech: 'sourceTech',
shouldDeps: {
tech: 'destTech',
}
})
}
}
}
},
bemdecl = [{ name: 'block', mods: [{ name: 'mod', vals: [{ name: 'val' }] }] }],
exepted = [{ name: 'block', mods: [{ name: 'mod', vals: [{ name: 'val' }] }] }];

return assert(scheme, bemdecl, exepted, { sourceTech: 'sourceTech', destTech: 'destTech' });
});

it('respect context for boolean mod', function () {
var scheme = {
blocks: {
block: {
_mod: {
'block_mod.deps.js': stringifyDepsJs({
tech: 'sourceTech',
shouldDeps: {
tech: 'destTech',
}
})
}
}
}
},
bemdecl = [{ name: 'block', mods: [{ name: 'mod', vals: [{ name: true }] }] }],
exepted = [{ name: 'block', mods: [{ name: 'mod', vals: [{ name: true }] }] }];

return assert(scheme, bemdecl, exepted, { sourceTech: 'sourceTech', destTech: 'destTech' });
});

it('respect context for elem', function () {
var scheme = {
blocks: {
block: {
__elem: {
'block__elem.deps.js': stringifyDepsJs({
tech: 'sourceTech',
shouldDeps: {
tech: 'destTech',
}
})
}
}
}
},
bemdecl = [{ name: 'block', elems: [{ name: 'elem' }] }],
exepted = [{ name: 'block', elems: [{ name: 'elem' }] }];

return assert(scheme, bemdecl, exepted, { sourceTech: 'sourceTech', destTech: 'destTech' });
});

it('respect context for elem mod', function () {
var scheme = {
blocks: {
block: {
__elem: {
_mod: {
'block__elem_mod_val.deps.js': stringifyDepsJs({
tech: 'sourceTech',
shouldDeps: {
tech: 'destTech',
}
})
}
}
}
}
},
bemdecl = [{ name: 'block', elems: [
{ name: 'elem', mods: [{ name: 'mod', vals: [{ name: 'val' }] }] }
] }],
exepted = [{ name: 'block', elems: [
{ name: 'elem', mods: [{ name: 'mod', vals: [{ name: 'val' }] }] }
] }];

return assert(scheme, bemdecl, exepted, { sourceTech: 'sourceTech', destTech: 'destTech' });
});

it('respect context for boolean mod of elem', function () {
var scheme = {
blocks: {
block: {
__elem: {
_mod: {
'block__elem_mod.deps.js': stringifyDepsJs({
tech: 'sourceTech',
shouldDeps: {
tech: 'destTech',
}
})
}
}
}
}
},
bemdecl = [{ name: 'block', elems: [
{ name: 'elem', mods: [{ name: 'mod', vals: [{ name: true }] }] }
] }],
exepted = [{ name: 'block', elems: [
{ name: 'elem', mods: [{ name: 'mod', vals: [{ name: true }] }] }
] }];

return assert(scheme, bemdecl, exepted, { sourceTech: 'sourceTech', destTech: 'destTech' });
});

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

0 comments on commit e90de63

Please sign in to comment.