Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JPeer264 committed Dec 8, 2016
2 parents b4309a4 + 573d6fc commit 4ec61e2
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/options/selectorLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,20 @@ class SelectorLibrary {
if (!toExclude) return;

if (typeof toExclude === 'string') {
if (this.contains.call(this.excludes, toExclude)) {
return
}

(this.excludes).push(toExclude);

return;
}

for (let e of toExclude) {
if (this.contains.call(this.excludes, e)) {
continue;
}

(this.excludes).push(e);
}
} // /setExclude
Expand Down
42 changes: 42 additions & 0 deletions test/selectorLibrary.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,46 @@ describe('rcs selector library', () => {
done();
});
});

describe('setExclude', () => {
beforeEach(() => {
rcs.selectorLibrary.excludes = []
});

it('should avoid adding more of the same exludes | should enable array', done => {
const excludes = [
'one-value',
'one-value',
'another-value'
];

rcs.selectorLibrary.setExclude(excludes);

expect(rcs.selectorLibrary.excludes.length).to.equal(2);

done();
});

it('should enable array', done => {
const excludes = [
'one-value',
'another-value'
];

rcs.selectorLibrary.setExclude(excludes);

expect(rcs.selectorLibrary.excludes.length).to.equal(2);

done();
});

it('should enable excludes', done => {
rcs.selectorLibrary.setExclude('one-value');
rcs.selectorLibrary.setExclude('second-value');

expect(rcs.selectorLibrary.excludes.length).to.equal(2);

done();
});
});
});

0 comments on commit 4ec61e2

Please sign in to comment.