mirror of
https://github.com/upgundecha/howtheysre
synced 2026-01-04 08:18:02 +00:00
Added uniqueness check
This commit is contained in:
@@ -38,4 +38,29 @@ describe('Checklist', function () {
|
||||
expect(orgList).to.be.sorted(Intl.Collator().compare);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Uniqueness', function() {
|
||||
it('has unique items', function () {
|
||||
var items = srcMd.match(/(?<=\* )(.*?)(?=\))/g);
|
||||
var hasDuplicate = items.some((val, i) => items.indexOf(val) !== i);
|
||||
expect(hasDuplicate).to.equal(false, 'List has duplicate items');
|
||||
});
|
||||
it('has unique link text', function () {
|
||||
var items = srcMd.match(/(?<=\* \[)(.*?)(?=\])/g);
|
||||
var hasDuplicate = items.some((val, i) => items.indexOf(val) !== i);
|
||||
expect(hasDuplicate).to.equal(false, 'List has duplicate text');
|
||||
});
|
||||
it('has unique urls', function () {
|
||||
var items = srcMd.match(/(?<=\* \[*.*\]\()(.*?)(?=\))/g);
|
||||
var items = arrayRemove(items, 'https://github.com/abhivaikar/howtheytest');
|
||||
var hasDuplicate = items.some((val, i) => items.indexOf(val) !== i);
|
||||
expect(hasDuplicate).to.equal(false, 'List has duplicate link');
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
function arrayRemove(arr, value) {
|
||||
return arr.filter(function(ele){
|
||||
return ele != value;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user