diff --git a/index.js b/index.js old mode 100644 new mode 100755 index 9799a05..4fece10 --- a/index.js +++ b/index.js @@ -24,6 +24,11 @@ function Filter(inputTree, options) { throw new TypeError('Filter is an abstract class and must be sub-classed'); } + // Validate that a single node was passed in + if (Array.isArray(inputTree)) { + throw new Error('inputTree should be a single tree, array was passed'); + } + var name = 'broccoli-filter:' + (this.constructor.name); if (this.description) { name += ' > [' + this.description + ']'; diff --git a/test/test.js b/test/test.js old mode 100644 new mode 100755 index 9dfca91..bb7a322 --- a/test/test.js +++ b/test/test.js @@ -112,6 +112,13 @@ describe('Filter', function() { }); + it('should throw if constructor is passed array of trees', function() { + expect(function() { + new IncompleteFilter(['.']); + }).to.throw(Error, /array was passed/); + }); + + it('should throw if `processString` is not implemented', function() { expect(function() { new IncompleteFilter('.').processString('foo', 'fake_path');