This repository was archived by the owner on Apr 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the way the weighted list is built
- Loading branch information
1 parent
7d37ebc
commit a71f404
Showing
2 changed files
with
79 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const { expect } = require('chai'); | ||
const findReviewersTask = require('../tasks/findReviewers'); | ||
|
||
describe('tasks/findReviewers', () => { | ||
describe('getPotentialReviewers()', () => { | ||
const getPotentialReviewers = findReviewersTask.getPotentialReviewers; | ||
|
||
it('should compute a weighted list of potential reviwers', () => { | ||
const reviewers = getPotentialReviewers( | ||
{ foo: 40, bar: 2, titi: 1 }, | ||
{ foo: 1, bar: 1, titi: 1 } | ||
); | ||
|
||
expect(reviewers).to.contain.all.keys(['foo', 'bar', 'titi']); | ||
}); | ||
|
||
it('should exclude non-collaborators', () => { | ||
const reviewers = getPotentialReviewers( | ||
{ foo: 40, bar: 2, titi: 1 }, | ||
{ foo: 1 } | ||
); | ||
|
||
expect(reviewers).to.contain.all.keys(['foo']); | ||
expect(reviewers).not.to.contain.all.keys(['bar', 'titi']); | ||
}); | ||
|
||
it('should return collaborators if no reviewers from authors', () => { | ||
const reviewers = getPotentialReviewers( | ||
{ foo: 40, bar: 2, titi: 1 }, | ||
{ babar: 1 } | ||
); | ||
|
||
expect(reviewers).to.contain.all.keys(['babar']); | ||
expect(reviewers).not.to.contain.all.keys(['foo', 'bar', 'titi']); | ||
}); | ||
|
||
it('should accept an empty set of authors', () => { | ||
const reviewers = getPotentialReviewers({}, { babar: 1, 'john-y': 1 }); | ||
|
||
expect(reviewers).to.contain.all.keys(['babar', 'john-y']); | ||
}); | ||
|
||
it('should accept an empty set of collaborators', () => { | ||
const reviewers = getPotentialReviewers({}, {}); | ||
|
||
expect(reviewers).to.deep.equal({}); | ||
}); | ||
|
||
it('should does not return any reviewer when no collaborators', () => { | ||
const reviewers = getPotentialReviewers({ boo: 23, baz: 1 }, {}); | ||
|
||
expect(reviewers).to.deep.equal({}); | ||
}); | ||
}); | ||
}); |