From 6ab90b65a1b38f96bfcfec514e4dbbf10a30b9ac Mon Sep 17 00:00:00 2001 From: Ilya Kashlakov Date: Mon, 4 Jul 2016 08:00:56 +0300 Subject: [PATCH] Test for preparing BEM entity before apply filters --- README.md | 6 +++--- test/lib/util.js | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c41ef44..498431b 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/test/lib/util.js b/test/lib/util.js index e3f48fd..c3ecf72 100644 --- a/test/lib/util.js +++ b/test/lib/util.js @@ -161,5 +161,31 @@ describe('util', function() { it('should return result with apply function', function() { assert.instanceOf(util.getFiltersForConditions().apply, Function); }); + + it('should prepare BEM entity before apply filter', function() { + var Filter = require('../../lib/filter'); + sinon.stub(Filter.prototype, 'apply', function() { + return true; + }); + var apply = util.getFiltersForConditions({ + blocks: ['foo'], + levels: [], + modifiers: [], + elements: [], + techs: [] + }).apply; + apply({ + entity: { + block: 'foo' + }, + tech: 'js' + }); + assert.equal(Filter.prototype.apply.calledOnce, true); + assert.equal(Filter.prototype.apply.calledWith({ + block: 'foo', + tech: 'js' + }), true); + Filter.prototype.apply.restore(); + }); }); });