-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16c7b08
commit 0823109
Showing
20 changed files
with
141 additions
and
110 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
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
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
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
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,28 @@ | ||
const parseFilter = require('../parseFilter'); | ||
|
||
describe('Interactors | getUsers | .parseFilter', () => { | ||
it('returns null when the input does not contain usernames or regexp', () => { | ||
expect(parseFilter()).toEqual(null); | ||
expect(parseFilter(null)).toEqual(null); | ||
expect(parseFilter('')).toEqual(null); | ||
expect(parseFilter('@')).toEqual(null); | ||
expect(parseFilter('/@/%^')).toEqual(null); | ||
}); | ||
|
||
it('splits usernames into an array', () => { | ||
expect(parseFilter('user1,user2')).toEqual(['user1', 'user2']); | ||
}); | ||
|
||
it('removes spaces and converts usernames to lowercase', () => { | ||
expect(parseFilter('User1, USER2')).toEqual(['user1', 'user2']); | ||
}); | ||
|
||
it('removes invalid characters from usernames', () => { | ||
expect(parseFilter('@user1, @user%2ñ, keep-dashes-ok')).toEqual(['user1', 'user2', 'keep-dashes-ok']); | ||
}); | ||
|
||
it('parses regexp strings', () => { | ||
expect(parseFilter('/user[0-9]/')).toEqual(/user[0-9]/); | ||
expect(parseFilter('/^bot-.*/ig')).toEqual(/^bot-.*/ig); | ||
}); | ||
}); |
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,30 @@ | ||
const testFilter = require('../testFilter'); | ||
|
||
describe('Interactors | getUsers | .testFilter', () => { | ||
const reviewers = [ | ||
'manuelmhtr', | ||
'jartmez', | ||
'bot1', | ||
'bot2', | ||
]; | ||
|
||
it('filters out reviewers by a list of usernames', () => { | ||
const filter = ['manuelmhtr', 'jartmez']; | ||
const results = reviewers.filter((reviewer) => testFilter(filter, reviewer)); | ||
expect(results.length).toEqual(2); | ||
expect(results).toEqual([ | ||
'manuelmhtr', | ||
'jartmez', | ||
]); | ||
}); | ||
|
||
it('filters out reviewers by a regular expression', () => { | ||
const filter = /bot/; | ||
const results = reviewers.filter((reviewer) => testFilter(filter, reviewer)); | ||
expect(results.length).toEqual(2); | ||
expect(results).toEqual([ | ||
'bot1', | ||
'bot2', | ||
]); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,11 +1,14 @@ | ||
const filterUser = require('./filterUser'); | ||
const testFilter = require('./testFilter'); | ||
const findUsers = require('./findUsers'); | ||
const parseExclude = require('./parseExclude'); | ||
const parseFilter = require('./parseFilter'); | ||
|
||
module.exports = (pulls, { excludeStr } = {}) => { | ||
const exclude = parseExclude(excludeStr); | ||
module.exports = (pulls, { excludeStr, includeStr } = {}) => { | ||
const include = parseFilter(includeStr); | ||
const exclude = parseFilter(excludeStr); | ||
const users = findUsers(pulls); | ||
|
||
return users | ||
.filter(({ login }) => filterUser(exclude, login)); | ||
.filter(({ login }) => !!login) | ||
.filter(({ login }) => !include || testFilter(include, login)) | ||
.filter(({ login }) => !exclude || !testFilter(exclude, login)); | ||
}; |
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,5 @@ | ||
module.exports = (filter, username) => { | ||
if (filter.test) return filter.test(username); | ||
if (filter.includes) return filter.includes(username); | ||
return false; | ||
}; |
Oops, something went wrong.