'use strict';

var chai = require('chai'),
    chaiAsPromised = require('chai-as-promised'),
    sinon = require('sinon');

if (!global.Promise) {
    global.Promise = require('promise-polyfill');
}
chai.use(chaiAsPromised);
chai.should();

var aplus = require('../../lib/aplus');

describe('filter functions', function () {
    function testFilter(select) {
        it('should filter array values', function () {
            var input = [1, 2, 3, 4, 5],
                expected = [4, 5];

            function filter(i) {
                return Promise.resolve(i > 3);
            }
            return select(input, filter).then(function (values) {
                values.should.eql(expected);
            });
        });
        it('should reject on inner promise rejection', function () {
            var input = [1, 2, 3, 4, 5],
                expected = new Error('i am error' + Math.random());

            function filter(i) {
                return Promise.reject(expected);
            }
            return select(input, filter).then(function () {
                chai.assert.fail('Should not accept promise');
            }).catch(function (rejection) {
                rejection.should.equal(expected);
            });
        });
        it('should reject on inner promise thrown error', function () {
            var input = [1, 2, 3, 4, 5],
                expected = new Error('i am error' + Math.random());

            function filter(i) {
                throw expected;
            }

            return select(input, filter).then(function () {
                chai.assert.fail('Should not accept promise');
            }).catch(function (rejection) {
                rejection.should.equal(expected);
            });
        });
    }

    var sandbox;
    beforeEach(function () {
        sandbox = sinon.sandbox.create();
        sandbox.spy(aplus, 'each');
        sandbox.spy(aplus, 'eachLimit');
        sandbox.spy(aplus, 'eachSeries');
    });
    afterEach(function () {
        sandbox.restore();
    });
    describe('aplus.selectLimit()', function () {
        it('should alias aplus.filterLimit to aplus.selectLimit', function () {
            aplus.filterLimit.should.equal(aplus.selectLimit);
        });
        it('should spawn Promises via aplus.eachLimit', function () {
            return aplus.selectLimit([1], 3, Promise.resolve).then(function (values) {
                aplus.eachLimit.called.should.equal(true);
            });
        });
        testFilter(function (arr, iterator) {
            return aplus.selectLimit(arr, 3, iterator);
        });
    });
    describe('aplus.select()', function () {
        it('should alias aplus.filter to aplus.select', function () {
            aplus.filter.should.equal(aplus.select);
        });
        it('should spawn Promises via aplus.eachLimit', function () {
            return aplus.select([1], Promise.resolve).then(function (values) {
                aplus.each.called.should.equal(true);
            });
        });
        testFilter(aplus.select);
    });
    describe('aplus.selectSeries()', function () {
        it('should alias aplus.filterSeries to aplus.selectSeries', function () {
            aplus.filterSeries.should.equal(aplus.selectSeries);
        });
        it('should spawn Promises via aplus.eachLimit', function () {
            return aplus.selectSeries([1], Promise.resolve).then(function (values) {
                aplus.eachSeries.called.should.equal(true);
            });
        });
        testFilter(aplus.selectSeries);
    });
});
@@ -916,37 +916,36 @@
 function filter(
-i
 ) %7B%0A
+
                 
@@ -1438,33 +1438,32 @@
 function filter(
-i
 ) %7B%0A            
@@ -2371,38 +2371,32 @@
 .then(function (
-values
 ) %7B%0A            
@@ -2903,38 +2903,32 @@
 .then(function (
-values
 ) %7B%0A            
@@ -3386,38 +3386,32 @@
 .then(function (
-values
 ) %7B%0A            
@@ -3534,11 +3534,12 @@
     %7D);%0A
-
 %7D);
+%0A

fix lint errors