Skip to content

Commit

Permalink
Make popout-square fall back to flat-square
Browse files Browse the repository at this point in the history
  • Loading branch information
PyvesB committed Jul 22, 2019
1 parent 774f86a commit 702c8e6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gh-badges/lib/make-badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ module.exports = function makeBadge({
}

if (!(template in templates)) {
template = 'flat'
if (template && template.endsWith('-square')) {
template = 'flat-square'
} else {
template = 'flat'
}
}
if (template === 'social') {
left = capitalize(left)
Expand Down
16 changes: 16 additions & 0 deletions gh-badges/lib/make-badge.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,22 @@ describe('The badge generator', function() {
.to.equal(jsonBadgeWithDefaultStyle)
.and.to.satisfy(isSvg)
})

it('should replace "popout-square" svg template with "flat-square"', function() {
const jsonBadgeWithUnknownStyle = makeBadge({
text: ['name', 'Bob'],
format: 'svg',
template: 'popout-square',
})
const jsonBadgeWithDefaultStyle = makeBadge({
text: ['name', 'Bob'],
format: 'svg',
template: 'flat-square',
})
expect(jsonBadgeWithUnknownStyle)
.to.equal(jsonBadgeWithDefaultStyle)
.and.to.satisfy(isSvg)
})
})

describe('"for-the-badge" template badge generation', function() {
Expand Down

0 comments on commit 702c8e6

Please sign in to comment.