mirror of
https://github.com/all-contributors/cli.git
synced 2025-01-09 13:36:29 +00:00
fix: set alt value for contributor image with no complete name (#335)
This commit is contained in:
parent
9d82568f41
commit
109b2614d2
3 changed files with 18 additions and 1 deletions
|
@ -25,6 +25,11 @@
|
||||||
"avatar_url": "https://avatars1.githubusercontent.com/u/1500684",
|
"avatar_url": "https://avatars1.githubusercontent.com/u/1500684",
|
||||||
"contributions": ["translation"]
|
"contributions": ["translation"]
|
||||||
},
|
},
|
||||||
|
"nocompletename": {
|
||||||
|
"login": "nocompletename",
|
||||||
|
"avatar_url": "https://avatars1.githubusercontent.com/u/1500684",
|
||||||
|
"contributions": ["translation"]
|
||||||
|
},
|
||||||
"nologin_badrole": {
|
"nologin_badrole": {
|
||||||
"name": "Wildly Misconfigured",
|
"name": "Wildly Misconfigured",
|
||||||
"avatar_url": "https://avatars1.githubusercontent.com/u/1500684",
|
"avatar_url": "https://avatars1.githubusercontent.com/u/1500684",
|
||||||
|
|
|
@ -77,3 +77,13 @@ test('format contributor with no GitHub account', () => {
|
||||||
|
|
||||||
expect(formatContributor(options, contributor)).toBe(expected)
|
expect(formatContributor(options, contributor)).toBe(expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('format contributor with no complete name', () => {
|
||||||
|
const contributor = contributors.nocompletename
|
||||||
|
const {options} = fixtures()
|
||||||
|
|
||||||
|
const expected =
|
||||||
|
'<img src="https://avatars1.githubusercontent.com/u/1500684?s=150" width="150px;" alt="nocompletename"/><br /><sub><b>nocompletename</b></sub><br /><a href="#translation-nocompletename" title="Translation">🌍</a>'
|
||||||
|
|
||||||
|
expect(formatContributor(options, contributor)).toBe(expected)
|
||||||
|
})
|
||||||
|
|
|
@ -17,7 +17,9 @@ const contributorTemplate = _.template(
|
||||||
const defaultImageSize = 100
|
const defaultImageSize = 100
|
||||||
|
|
||||||
function defaultTemplate(templateData) {
|
function defaultTemplate(templateData) {
|
||||||
const name = escapeName(templateData.contributor.name)
|
const rawName =
|
||||||
|
templateData.contributor.name || templateData.contributor.login
|
||||||
|
const name = escapeName(rawName)
|
||||||
const avatar = avatarTemplate(
|
const avatar = avatarTemplate(
|
||||||
_.assign(templateData, {
|
_.assign(templateData, {
|
||||||
name,
|
name,
|
||||||
|
|
Loading…
Reference in a new issue