-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Wrong contribution type being added to .all-contributorsrc (#78)
* initial issue fix * tests added * revert unneisary lint change to untouched file * added myself * no contribution types when adding a contributor error handled * revert commit 1bdb51e * reverted readme back to commit# f697c73 * further reverted Readme to master * removed generated index from rm * removed generated index from rm * breaking change to cli fixed: * Update prompt.js * Update prompt.js * added code and test in my contribution * list of invalid contributions added in error message Closes #71
- Loading branch information
1 parent
c4a0484
commit 526d4db
Showing
4 changed files
with
89 additions
and
3 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,59 @@ | ||
import prompt from '../prompt' | ||
|
||
function fixtures() { | ||
const options = { | ||
contributors: [ | ||
{ | ||
login: 'jfmengels', | ||
name: 'Jeroen Engels', | ||
avatar_url: 'https://avatars.githubusercontent.com/u/3869412?v=3', | ||
profile: 'https://github.com/jfmengels', | ||
contributions: [], | ||
}, | ||
{ | ||
login: 'kentcdodds', | ||
name: 'Kent C. Dodds', | ||
avatar_url: 'https://avatars.githubusercontent.com/u/1500684?v=3', | ||
profile: 'http://kentcdodds.com/', | ||
contributions: [], | ||
}, | ||
{ | ||
login: 'jccguimaraes', | ||
name: 'João Guimarães', | ||
avatar_url: 'https://avatars.githubusercontent.com/u/14871650?v=3', | ||
profile: 'https://github.com/jccguimaraes', | ||
contributions: [], | ||
}, | ||
], | ||
} | ||
return options | ||
} | ||
|
||
test(`should throw error if all contribution types are invalid`, () => { | ||
const options = fixtures() | ||
const username = 'userName' | ||
const contributions = 'invalidContributionType1,invalidContributionType2' | ||
expect(() => prompt(options, username, contributions)).toThrow( | ||
'invalidContributionType1,invalidContributionType2 is/are invalid contribution type(s)', | ||
) | ||
}) | ||
|
||
test(`should not throw error if atleast one of the contribution types is valid`, () => { | ||
const options = fixtures() | ||
const username = 'userName' | ||
const contributions = 'wrongContributionType,code' | ||
return prompt(options, username, contributions).then(answers => { | ||
expect(answers).toEqual({username: 'userName', contributions: ['code']}) | ||
}) | ||
}) | ||
|
||
test(`should filter valid contribution types from user inserted types`, () => { | ||
const options = fixtures() | ||
const username = 'userName' | ||
const contributions = | ||
'invalidContributionType1,code,invalidContributionType2,bug' | ||
return prompt(options, username, contributions).then(answers => { | ||
expect(answers.contributions.length).toBe(2) | ||
expect(answers.contributions).toEqual(['code', 'bug']) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
const _ = require('lodash/fp') | ||
|
||
const util = require('../util') | ||
|
||
const linkTemplate = _.template( | ||
|