Skip to content

Commit

Permalink
Merge pull request #32 from bem/issue-29
Browse files Browse the repository at this point in the history
Update `harry-roberts` tests
  • Loading branch information
Andrew Abramov committed Aug 21, 2014
2 parents fc1bf1c + 70b67b7 commit 6aab004
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 32 deletions.
6 changes: 3 additions & 3 deletions test/harry-roberts/isBlock.test.js
Expand Up @@ -49,7 +49,7 @@ describe('harry roberts', function () {
});

it('should not detect block in elem by string', function () {
naming.isBlock('block-elem').should.be.false;
naming.isBlock('block__elem').should.be.false;
});

it('should not detect block in elem by object', function () {
Expand All @@ -59,7 +59,7 @@ describe('harry roberts', function () {
});

it('should not detect block in mod of elem by string', function () {
naming.isBlock('block-elem--mod--value').should.be.false;
naming.isBlock('block__elem--mod--value').should.be.false;
});

it('should not detect block in mod of elem by object', function () {
Expand All @@ -69,7 +69,7 @@ describe('harry roberts', function () {
});

it('should not detect block in boolean mod of elem by string', function () {
naming.isBlock('block-elem--mod').should.be.false;
naming.isBlock('block__elem--mod').should.be.false;
});

it('should not detect block in boolean mod of elem by object', function () {
Expand Down
6 changes: 3 additions & 3 deletions test/harry-roberts/isBlockMod.test.js
Expand Up @@ -59,7 +59,7 @@ describe('harry roberts', function () {
});

it('should not detect mod of block in elem by string', function () {
naming.isBlockMod('block-elem').should.be.false;
naming.isBlockMod('block__elem').should.be.false;
});

it('should not detect mod of block in elem by object', function () {
Expand All @@ -69,7 +69,7 @@ describe('harry roberts', function () {
});

it('should not detect mod of block in mod of elem by string', function () {
naming.isBlockMod('block-elem--mod--val').should.be.false;
naming.isBlockMod('block__elem--mod--val').should.be.false;
});

it('should not detect mod of block in mod of elem by object', function () {
Expand All @@ -79,7 +79,7 @@ describe('harry roberts', function () {
});

it('should not detect mod of block in boolean mod of elem by string', function () {
naming.isBlockMod('block-elem--mod').should.be.false;
naming.isBlockMod('block__elem--mod').should.be.false;
});

it('should not detect mod of block in boolean mod of elem by object', function () {
Expand Down
6 changes: 3 additions & 3 deletions test/harry-roberts/isElem.test.js
Expand Up @@ -53,7 +53,7 @@ describe('harry roberts', function () {
});

it('should detect elem by string', function () {
naming.isElem('block-elem').should.be.true;
naming.isElem('block__elem').should.be.true;
});

it('should detect elem by object', function () {
Expand All @@ -63,7 +63,7 @@ describe('harry roberts', function () {
});

it('should not detect elem in mod of elem by string', function () {
naming.isElem('block-elem--mod--val').should.be.false;
naming.isElem('block__elem--mod--val').should.be.false;
});

it('should not detect elem in mod of elem by object', function () {
Expand All @@ -73,7 +73,7 @@ describe('harry roberts', function () {
});

it('should not detect elem in boolean mod of elem by string', function () {
naming.isElem('block-elem--mod').should.be.false;
naming.isElem('block__elem--mod').should.be.false;
});

it('should not detect elem in boolean mod of elem by object', function () {
Expand Down
6 changes: 3 additions & 3 deletions test/harry-roberts/isElemMod.test.js
Expand Up @@ -53,7 +53,7 @@ describe('harry roberts', function () {
});

it('should not detect mod of elem in elem by string', function () {
naming.isElemMod('block-elem').should.be.false;
naming.isElemMod('block__elem').should.be.false;
});

it('should not detect mod of elem in elem by object', function () {
Expand All @@ -63,7 +63,7 @@ describe('harry roberts', function () {
});

it('should detect mod of elem by string', function () {
naming.isElemMod('block-elem--mod--val').should.be.true;
naming.isElemMod('block__elem--mod--val').should.be.true;
});

it('should detect mod of elem by object', function () {
Expand All @@ -73,7 +73,7 @@ describe('harry roberts', function () {
});

it('should detect boolean mod of elem by string', function () {
naming.isElemMod('block-elem--mod').should.be.true;
naming.isElemMod('block__elem--mod').should.be.true;
});

it('should detect boolean mod of elem by object without `modVal` field', function () {
Expand Down
10 changes: 5 additions & 5 deletions test/harry-roberts/parse.test.js
Expand Up @@ -22,13 +22,13 @@ describe('harry roberts', function () {
});

it('should have two params if parse elem of block', function () {
var obj = naming.parse('block-elem');
var obj = naming.parse('block__elem');

Object.keys(obj).should.have.length(2);
});

it('should have four params if parse mod of elem', function () {
var obj = naming.parse('block-elem--mod');
var obj = naming.parse('block__elem--mod');

Object.keys(obj).should.have.length(4);
});
Expand Down Expand Up @@ -56,14 +56,14 @@ describe('harry roberts', function () {
});

it('should parse elem', function () {
var obj = naming.parse('block-elem');
var obj = naming.parse('block__elem');

obj.block.should.equal('block');
obj.elem.should.equal('elem');
});

it('should parse mod of elem', function () {
var obj = naming.parse('block-elem--mod--val');
var obj = naming.parse('block__elem--mod--val');

obj.block.should.equal('block');
obj.elem.should.equal('elem');
Expand All @@ -72,7 +72,7 @@ describe('harry roberts', function () {
});

it('should parse boolean mod of elem', function () {
var obj = naming.parse('block-elem--mod');
var obj = naming.parse('block__elem--mod');

obj.block.should.equal('block');
obj.modName.should.equal('mod');
Expand Down
10 changes: 5 additions & 5 deletions test/harry-roberts/stringify.test.js
Expand Up @@ -58,7 +58,7 @@ describe('harry roberts', function () {
elem: 'elem'
});

str.should.equal('block-elem');
str.should.equal('block__elem');
});

it('should stringify mod of elem', function () {
Expand All @@ -69,7 +69,7 @@ describe('harry roberts', function () {
modVal: 'val'
});

str.should.equal('block-elem--mod--val');
str.should.equal('block__elem--mod--val');
});

it('should stringify boolean mod of elem', function () {
Expand All @@ -80,7 +80,7 @@ describe('harry roberts', function () {
modVal: true
});

str.should.equal('block-elem--mod');
str.should.equal('block__elem--mod');
});

it('should stringify boolean mod of elem by strict notation', function () {
Expand All @@ -91,7 +91,7 @@ describe('harry roberts', function () {
modVal: true
});

str.should.equal('block-elem--mod');
str.should.equal('block__elem--mod');
});

it('should stringify elem if `modVal` filed is `undefined`', function () {
Expand All @@ -102,7 +102,7 @@ describe('harry roberts', function () {
modVal: undefined
});

str.should.equal('block-elem');
str.should.equal('block__elem');
});
});
});
18 changes: 9 additions & 9 deletions test/harry-roberts/validate.test.js
Expand Up @@ -15,19 +15,19 @@ describe('harry roberts', function () {
});

it('should validate elem', function () {
naming.validate('block-elem').should.be.true;
naming.validate('block__elem').should.be.true;
});

it('should validate mod of elem', function () {
naming.validate('block-elem--mod--value').should.be.true;
naming.validate('block__elem--mod--value').should.be.true;
});

it('should validate boolean mod of elem', function () {
naming.validate('block-elem--mod').should.be.true;
naming.validate('block__elem--mod').should.be.true;
});

it('should not validate elem without block', function () {
naming.validate('-elem').should.be.false;
naming.validate('__elem').should.be.false;
});

it('should not validate boolean mod without block', function () {
Expand All @@ -39,23 +39,23 @@ describe('harry roberts', function () {
});

it('should not validate mod of elem without block', function () {
naming.validate('-elem--mod--val').should.be.false;
naming.validate('__elem--mod--val').should.be.false;
});

it('should not validate boolean mod of elem without block', function () {
naming.validate('-elem--mod').should.be.false;
naming.validate('__elem--mod').should.be.false;
});

it('should not validate nested elem', function () {
naming.validate('block-elem1-elem2').should.be.false;
naming.validate('block__elem1__elem2').should.be.false;
});

it('should not validate multi mod', function () {
naming.validate('block--mod--val-elem--mod--val').should.be.false;
naming.validate('block--mod--val__elem--mod--val').should.be.false;
});

it('should not validate block name with illegal literals', function () {
naming.validate('block__elem').should.be.false;
naming.validate('block_elem').should.be.false;
});
});
});
2 changes: 1 addition & 1 deletion test/lib/harry-roberts-naming.js
@@ -1,3 +1,3 @@
var BEMNaming = require('../../lib/bem-naming').BEMNaming;

module.exports = new BEMNaming({ elemSeparator: '-', modSeparator: '--', literal: '[a-zA-Z0-9]' });
module.exports = new BEMNaming({ elem: '__', mod: '--' });

0 comments on commit 6aab004

Please sign in to comment.