Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default for bem-config and support for latest bem-walker #10

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# bem-tools-find

[![NPM version](http://img.shields.io/npm/v/bem-tools-find.svg?style=flat)](http://www.npmjs.org/package/bem-tools-find)
[![Build Status](https://travis-ci.org/bem-incubator/bem-tools-find.svg)](https://travis-ci.org/bem-incubator/bem-tools-find)
[![Coverage Status](https://coveralls.io/repos/bem-incubator/bem-tools-find/badge.svg?branch=master&service=github)](https://coveralls.io/github/bem-incubator/bem-tools-find?branch=master)
[![David](https://img.shields.io/david/bem-incubator/bem-tools-find.svg)](https://david-dm.org/bem-incubator/bem-tools-find)
[![Build Status](https://travis-ci.org/bem-contrib/bem-tools-find.svg)](https://travis-ci.org/bem-contrib/bem-tools-find)
[![Coverage Status](https://coveralls.io/repos/bem-contrib/bem-tools-find/badge.svg?branch=master&service=github)](https://coveralls.io/github/bem-contrib/bem-tools-find?branch=master)
[![David](https://img.shields.io/david/bem-contrib/bem-tools-find.svg)](https://david-dm.org/bem-contrib/bem-tools-find)

![Logo](./logo.ico)

Expand Down
2 changes: 1 addition & 1 deletion lib/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Filter.prototype = {
* @private
*/
_byBlock: function(item) {
return this._shouldPass(item, 'blocks', 'block');
return this._shouldPass(item.entity, 'blocks', 'block');
},

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ exports.conditionsFromBEMItems = function(items) {
* @returns {Object}
*/
exports.initializeConfig = function(config) {
config = config.extended;
config = config.extended || {};

/**
* Returns list of levels
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"JSONStream": "^1.0.7",
"bem-config": "git://github.com/bem-incubator/bem-config.git",
"bem-naming": "^0.5.1",
"bem-walk": "0.0.4",
"bem-walk": "1.0.0-1",
"chalk": "^1.1.1",
"coa": "^1.0.1",
"flow-tostring": "^1.0.1",
Expand Down
94 changes: 79 additions & 15 deletions test/lib/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,56 @@ var Filter = require('../../lib/filter');

describe('Filter', function() {
describe('apply', function() {
testBySingleCriteria_('blocks', 'block');
testBySingleCriteria_('elements', 'elem');
testBySingleCriteria_('modifiers', 'modName');
testBySingleCriteria_('techs', 'tech');

it('should pass block item if no info about blocks provided in config', function() {
var filter = new Filter({}),
item = {
entity: {
block: 'foo'
}
};
assert.equal(filter.apply(item), true);
});

it('should pass block item if block matches blocks to search', function() {
var opts = {
blocks: 'foo'
};
var filter = new Filter(opts),
item = {
entity: {
block: 'foo'
}
};
assert.equal(filter.apply(item), true);
});

it('should not pass block item if block not match blocks to search', function() {
var opts = {
blocks: ['foo']
};
var filter = new Filter(opts),
item = {
entity: {
block: 'bar'
}
};

assert.equal(filter.apply(item), false);
});

it('should not pass if matches block, but not matches elem', function() {
var filter = new Filter({
blocks: ['foo'],
elements: ['bar']
}),
item = {
block: 'foo',
entity: {
block: 'foo'
},
elem: 'baz'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Очень странно, почему блок в энтити, а елем отдельно?

};

Expand All @@ -28,7 +66,9 @@ describe('Filter', function() {
elements: ['bar']
}),
item = {
block: 'foo',
entity: {
block: 'foo'
},
elem: 'bar'
};

Expand All @@ -41,7 +81,9 @@ describe('Filter', function() {
modifiers: ['bar']
}),
item = {
block: 'foo',
entity: {
block: 'foo'
},
modName: 'baz'
};

Expand All @@ -54,7 +96,9 @@ describe('Filter', function() {
modifiers: ['bar']
}),
item = {
block: 'foo',
entity: {
block: 'foo'
},
modName: 'bar'
};

Expand All @@ -67,7 +111,9 @@ describe('Filter', function() {
techs: ['bar']
}),
item = {
block: 'foo',
entity: {
block: 'foo'
},
tech: 'baz'
};

Expand All @@ -80,7 +126,9 @@ describe('Filter', function() {
techs: ['bar']
}),
item = {
block: 'foo',
entity: {
block: 'foo'
},
tech: 'bar'
};

Expand All @@ -94,7 +142,9 @@ describe('Filter', function() {
modifiers: ['fizz']
}),
item = {
block: 'foo',
entity: {
block: 'foo'
},
elem: 'bar',
modName: 'buzz'
};
Expand All @@ -109,7 +159,9 @@ describe('Filter', function() {
modifiers: ['fizz']
}),
item = {
block: 'foo',
entity: {
block: 'foo'
},
elem: 'bar',
modName: 'fizz'
};
Expand All @@ -125,7 +177,9 @@ describe('Filter', function() {
techs: ['buzz']
}),
item = {
block: 'foo',
entity: {
block: 'foo'
},
elem: 'bar',
modName: 'fizz',
tech: 'BAZ'
Expand All @@ -142,7 +196,9 @@ describe('Filter', function() {
techs: ['buzz']
}),
item = {
block: 'foo',
entity: {
block: 'foo'
},
elem: 'bar',
modName: 'fizz',
tech: 'buzz'
Expand All @@ -158,7 +214,9 @@ describe('Filter', function() {
techs: ['buzz']
}),
item = {
block: 'foo',
entity: {
block: 'foo'
},
elem: 'bar',
tech: 'BAZ'
};
Expand All @@ -173,7 +231,9 @@ describe('Filter', function() {
techs: ['buzz']
}),
item = {
block: 'foo',
entity: {
block: 'foo'
},
elem: 'bar',
tech: 'buzz'
};
Expand All @@ -188,7 +248,9 @@ describe('Filter', function() {
techs: ['buzz']
}),
item = {
block: 'foo',
entity: {
block: 'foo'
},
modName: 'fizz',
tech: 'BAZ'
};
Expand All @@ -203,7 +265,9 @@ describe('Filter', function() {
techs: ['buzz']
}),
item = {
block: 'foo',
entity: {
block: 'foo'
},
modName: 'fizz',
tech: 'buzz'
};
Expand Down