Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: set alt value for contributor image #334

Merged
merged 1 commit into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/generate/__tests__/format-contributor.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test('format a simple contributor', () => {
const {options} = fixtures()

const expected =
'<a href="http://kentcdodds.com"><img src="https://avatars1.githubusercontent.com/u/1500684?s=150" width="150px;" alt=""/><br /><sub><b>Kent C. Dodds</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/pulls?q=is%3Apr+reviewed-by%3Akentcdodds" title="Reviewed Pull Requests">👀</a>'
'<a href="http://kentcdodds.com"><img src="https://avatars1.githubusercontent.com/u/1500684?s=150" width="150px;" alt="Kent C. Dodds"/><br /><sub><b>Kent C. Dodds</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/pulls?q=is%3Apr+reviewed-by%3Akentcdodds" title="Reviewed Pull Requests">👀</a>'

expect(formatContributor(options, contributor)).toBe(expected)
})
Expand All @@ -30,7 +30,7 @@ test('format contributor with complex contribution types', () => {
const {options} = fixtures()

const expected =
'<a href="http://kentcdodds.com"><img src="https://avatars1.githubusercontent.com/u/1500684?s=150" width="150px;" alt=""/><br /><sub><b>Kent C. Dodds</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/commits?author=kentcdodds" title="Documentation">📖</a> <a href="https://github.com/all-contributors/all-contributors-cli/pulls?q=is%3Apr+reviewed-by%3Akentcdodds" title="Reviewed Pull Requests">👀</a> <a href="#question-kentcdodds" title="Answering Questions">💬</a>'
'<a href="http://kentcdodds.com"><img src="https://avatars1.githubusercontent.com/u/1500684?s=150" width="150px;" alt="Kent C. Dodds"/><br /><sub><b>Kent C. Dodds</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/commits?author=kentcdodds" title="Documentation">📖</a> <a href="https://github.com/all-contributors/all-contributors-cli/pulls?q=is%3Apr+reviewed-by%3Akentcdodds" title="Reviewed Pull Requests">👀</a> <a href="#question-kentcdodds" title="Answering Questions">💬</a>'

expect(formatContributor(options, contributor)).toBe(expected)
})
Expand All @@ -53,7 +53,7 @@ test('default image size to 100', () => {
delete options.imageSize

const expected =
'<a href="http://kentcdodds.com"><img src="https://avatars1.githubusercontent.com/u/1500684?s=100" width="100px;" alt=""/><br /><sub><b>Kent C. Dodds</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/pulls?q=is%3Apr+reviewed-by%3Akentcdodds" title="Reviewed Pull Requests">👀</a>'
'<a href="http://kentcdodds.com"><img src="https://avatars1.githubusercontent.com/u/1500684?s=100" width="100px;" alt="Kent C. Dodds"/><br /><sub><b>Kent C. Dodds</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/pulls?q=is%3Apr+reviewed-by%3Akentcdodds" title="Reviewed Pull Requests">👀</a>'

expect(formatContributor(options, contributor)).toBe(expected)
})
Expand All @@ -63,7 +63,7 @@ test('format contributor with pipes in their name', () => {
const {options} = fixtures()

const expected =
'<a href="http://github.com/chrisinajar"><img src="https://avatars1.githubusercontent.com/u/1500684?s=150" width="150px;" alt=""/><br /><sub><b>Who &#124; Needs &#124; Pipes?</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/commits?author=pipey" title="Documentation">📖</a>'
'<a href="http://github.com/chrisinajar"><img src="https://avatars1.githubusercontent.com/u/1500684?s=150" width="150px;" alt="Who &#124; Needs &#124; Pipes?"/><br /><sub><b>Who &#124; Needs &#124; Pipes?</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/commits?author=pipey" title="Documentation">📖</a>'

expect(formatContributor(options, contributor)).toBe(expected)
})
Expand All @@ -73,7 +73,7 @@ test('format contributor with no GitHub account', () => {
const {options} = fixtures()

const expected =
'<img src="https://avatars1.githubusercontent.com/u/1500684?s=150" width="150px;" alt=""/><br /><sub><b>No Github Account</b></sub><br /><a href="#translation" title="Translation">🌍</a>'
'<img src="https://avatars1.githubusercontent.com/u/1500684?s=150" width="150px;" alt="No Github Account"/><br /><sub><b>No Github Account</b></sub><br /><a href="#translation" title="Translation">🌍</a>'

expect(formatContributor(options, contributor)).toBe(expected)
})
2 changes: 1 addition & 1 deletion src/generate/format-contributor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const _ = require('lodash/fp')
const formatContributionType = require('./format-contribution-type')

const avatarTemplate = _.template(
'<img src="<%= contributor.avatar_url %>?s=<%= options.imageSize %>" width="<%= options.imageSize %>px;" alt=""/>',
'<img src="<%= contributor.avatar_url %>?s=<%= options.imageSize %>" width="<%= options.imageSize %>px;" alt="<%= name %>"/>',
)
const avatarBlockTemplate = _.template(
'<a href="<%= contributor.profile %>"><%= avatar %><br /><sub><b><%= name %></b></sub></a>',
Expand Down