Skip to content

Commit 4ec61e2

Browse files
committed
2 parents b4309a4 + 573d6fc commit 4ec61e2

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

lib/options/selectorLibrary.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,20 @@ class SelectorLibrary {
269269
if (!toExclude) return;
270270

271271
if (typeof toExclude === 'string') {
272+
if (this.contains.call(this.excludes, toExclude)) {
273+
return
274+
}
275+
272276
(this.excludes).push(toExclude);
273277

274278
return;
275279
}
276280

277281
for (let e of toExclude) {
282+
if (this.contains.call(this.excludes, e)) {
283+
continue;
284+
}
285+
278286
(this.excludes).push(e);
279287
}
280288
} // /setExclude

test/selectorLibrary.spec.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,46 @@ describe('rcs selector library', () => {
197197
done();
198198
});
199199
});
200+
201+
describe('setExclude', () => {
202+
beforeEach(() => {
203+
rcs.selectorLibrary.excludes = []
204+
});
205+
206+
it('should avoid adding more of the same exludes | should enable array', done => {
207+
const excludes = [
208+
'one-value',
209+
'one-value',
210+
'another-value'
211+
];
212+
213+
rcs.selectorLibrary.setExclude(excludes);
214+
215+
expect(rcs.selectorLibrary.excludes.length).to.equal(2);
216+
217+
done();
218+
});
219+
220+
it('should enable array', done => {
221+
const excludes = [
222+
'one-value',
223+
'another-value'
224+
];
225+
226+
rcs.selectorLibrary.setExclude(excludes);
227+
228+
expect(rcs.selectorLibrary.excludes.length).to.equal(2);
229+
230+
done();
231+
});
232+
233+
it('should enable excludes', done => {
234+
rcs.selectorLibrary.setExclude('one-value');
235+
rcs.selectorLibrary.setExclude('second-value');
236+
237+
expect(rcs.selectorLibrary.excludes.length).to.equal(2);
238+
239+
done();
240+
});
241+
});
200242
});

0 commit comments

Comments
 (0)