-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pref: reduce the count of regular matches (#295)
- Loading branch information
Showing
2 changed files
with
70 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,11 @@ import { | |
defaultReleaseTagURLHandler, | ||
defaultReleaseTagsURLHandler, | ||
findMapAuthorByEmail, | ||
findMapAuthorByGitHub, | ||
findMapAuthorByName, | ||
findMapAuthorLink, | ||
getAvatarFromGithubNoreplyAddress, | ||
getCoAuthors, | ||
getProfileUrlFromGithubNoreplyAddress, | ||
getGitHubUserNameFromNoreplyAddress, | ||
mergeRawCommits, | ||
newAvatarForAuthor, | ||
parseCommitAuthors, | ||
|
@@ -333,7 +333,8 @@ describe('parseCommitAuthors', () => { | |
{ | ||
name: 'First Last', | ||
email: '[email protected]', | ||
avatarUrl: 'https://avatars.githubusercontent.com/user?size=80', | ||
i18n: undefined, | ||
avatarUrl: 'https://github.com/user.png', | ||
url: 'https://github.com/user', | ||
}, | ||
]) | ||
|
@@ -385,6 +386,37 @@ describe('findMapAuthorByEmail', () => { | |
}) | ||
}) | ||
|
||
describe('findMapAuthorByGitHub', () => { | ||
it('should return the commit author for GitHub noreply email with username in mapAuthors', async () => { | ||
const creators: Contributor[] = [ | ||
{ | ||
name: 'John', | ||
username: 'user', | ||
}, | ||
] | ||
const creator = await findMapAuthorByGitHub(creators, 'John', '[email protected]') | ||
|
||
expect(creator).toEqual(creators[0]) | ||
}) | ||
|
||
it('should return the commit author for GitHub noreply email without username in mapAuthors', async () => { | ||
const creators: Contributor[] = [ | ||
{ | ||
name: 'user', | ||
}, | ||
] | ||
const creator = await findMapAuthorByGitHub(creators, 'user', '[email protected]') | ||
|
||
expect(creator).toEqual({ name: 'user', username: 'user' }) | ||
}) | ||
|
||
it('should return the commit author avatar for GitHub noreply email without mapAuthor', async () => { | ||
const avatar = await findMapAuthorByGitHub(undefined, 'John', '[email protected]') | ||
|
||
expect(avatar).toEqual({ name: 'John', username: 'user' }) | ||
}) | ||
}) | ||
|
||
describe('findMapAuthorByName', () => { | ||
it('should return the registered creator by name', () => { | ||
const creators: Contributor[] = [ | ||
|
@@ -559,57 +591,25 @@ describe('newAvatarForAuthor', () => { | |
|
||
expect(avatar).toEqual('https://gravatar.com/avatar/b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514?d=retro') | ||
}) | ||
|
||
it('should return the commit author avatar for GitHub noreply email without user ID', async () => { | ||
const avatar = await newAvatarForAuthor(undefined, '[email protected]') | ||
|
||
expect(avatar).toEqual('https://avatars.githubusercontent.com/user?size=80') | ||
}) | ||
|
||
it('should return the commit author avatar for GitHub noreply email with user ID', async () => { | ||
const avatar = await newAvatarForAuthor(undefined, '[email protected]') | ||
|
||
expect(avatar).toEqual('https://avatars.githubusercontent.com/u/123456?size=80') | ||
}) | ||
}) | ||
|
||
describe('getAvatarFromGithubNoreplyAddress', () => { | ||
it('should return undefined for email it cannot handle', async () => { | ||
const avatar = await getAvatarFromGithubNoreplyAddress('[email protected]') | ||
|
||
expect(avatar).toEqual(undefined) | ||
}) | ||
|
||
it('should return the commit author avatar for GitHub noreply email without user ID', async () => { | ||
const avatar = await getAvatarFromGithubNoreplyAddress('[email protected]') | ||
|
||
expect(avatar).toEqual('https://avatars.githubusercontent.com/user?size=80') | ||
}) | ||
|
||
it('should return the commit author avatar for GitHub noreply email with user ID', async () => { | ||
const avatar = await getAvatarFromGithubNoreplyAddress('[email protected]') | ||
|
||
expect(avatar).toEqual('https://avatars.githubusercontent.com/u/123456?size=80') | ||
}) | ||
}) | ||
|
||
describe('getProfileUrlFromGithubNoreplyAddress', () => { | ||
describe('getGitHubFromGithubNoreplyAddress', () => { | ||
it('should return undefined for email it cannot handle', async () => { | ||
const avatar = await getProfileUrlFromGithubNoreplyAddress('[email protected]') | ||
const result = await getGitHubUserNameFromNoreplyAddress('[email protected]') | ||
|
||
expect(avatar).toEqual(undefined) | ||
expect(result).toEqual(undefined) | ||
}) | ||
|
||
it('should return the GitHub profile URL for GitHub noreply email without user ID', async () => { | ||
const avatar = await getProfileUrlFromGithubNoreplyAddress('[email protected]') | ||
it('should return the commit author for GitHub noreply email without user ID', async () => { | ||
const result = await getGitHubUserNameFromNoreplyAddress('[email protected]') | ||
|
||
expect(avatar).toEqual('https://github.com/user') | ||
expect(result).toEqual({ userId: undefined, userName: 'user' }) | ||
}) | ||
|
||
it('should return the GitHub profile URL for GitHub noreply email with user ID', async () => { | ||
const avatar = await getProfileUrlFromGithubNoreplyAddress('[email protected]') | ||
it('should return the commit author for GitHub noreply email with user ID', async () => { | ||
const result = await getGitHubUserNameFromNoreplyAddress('[email protected]') | ||
|
||
expect(avatar).toEqual('https://github.com/user') | ||
expect(result).toEqual({ userId: '123456', userName: 'user' }) | ||
}) | ||
}) | ||
|
||
|
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