Skip to content

Commit

Permalink
Align style prop of coalesceBadge() with internal makeBadge() (#…
Browse files Browse the repository at this point in the history
…5726)

This is an analogous change to #5719 for `’template’` and `’style’`. (See the top comment for more explanation.)
  • Loading branch information
paulmelnikow authored Oct 20, 2020
1 parent d60b90b commit f1a5dd9
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 56 deletions.
6 changes: 0 additions & 6 deletions badge-maker/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ function _clean(format) {
// Legacy.
cleaned.label = cleaned.label || ''

// convert "public" format to "internal" format
if ('style' in cleaned) {
cleaned.template = cleaned.style
delete cleaned.style
}

return cleaned
}

Expand Down
6 changes: 3 additions & 3 deletions badge-maker/lib/make-badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ it is likely this will impact on the package's public interface in index.js
*/
module.exports = function makeBadge({
format,
template = 'flat',
style = 'flat',
label,
message,
color,
Expand Down Expand Up @@ -43,9 +43,9 @@ module.exports = function makeBadge({
})
}

const render = badgeRenderers[template]
const render = badgeRenderers[style]
if (!render) {
throw new Error(`Unknown template: '${template}'`)
throw new Error(`Unknown badge style: '${style}'`)
}

logoWidth = +logoWidth || (logo ? 14 : 0)
Expand Down
78 changes: 39 additions & 39 deletions badge-maker/lib/make-badge.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe('The badge generator', function () {
label: 'name',
message: 'Bob',
format: 'svg',
template: 'flat',
style: 'flat',
})
expect(jsonBadgeWithUnknownStyle)
.to.equal(jsonBadgeWithDefaultStyle)
Expand All @@ -136,9 +136,9 @@ describe('The badge generator', function () {
label: 'name',
message: 'Bob',
format: 'svg',
template: 'unknown_style',
style: 'unknown_style',
})
).to.throw(Error, "Unknown template: 'unknown_style'")
).to.throw(Error, "Unknown badge style: 'unknown_style'")
})
})

Expand All @@ -148,7 +148,7 @@ describe('The badge generator', function () {
label: 'cactus',
message: 'grown',
format: 'svg',
template: 'flat',
style: 'flat',
color: '#b3e',
labelColor: '#0f0',
})
Expand All @@ -159,7 +159,7 @@ describe('The badge generator', function () {
label: 'cactus',
message: 'grown',
format: 'svg',
template: 'flat',
style: 'flat',
color: '#b3e',
labelColor: '#0f0',
logo: 'data:image/svg+xml;base64,PHN2ZyB4bWxu',
Expand All @@ -171,7 +171,7 @@ describe('The badge generator', function () {
label: '',
message: 'grown',
format: 'svg',
template: 'flat',
style: 'flat',
color: '#b3e',
})
})
Expand All @@ -181,7 +181,7 @@ describe('The badge generator', function () {
label: '',
message: 'grown',
format: 'svg',
template: 'flat',
style: 'flat',
color: '#b3e',
logo: 'data:image/svg+xml;base64,PHN2ZyB4bWxu',
})
Expand All @@ -192,7 +192,7 @@ describe('The badge generator', function () {
label: '',
message: 'grown',
format: 'svg',
template: 'flat',
style: 'flat',
color: '#b3e',
labelColor: '#0f0',
logo: 'data:image/svg+xml;base64,PHN2ZyB4bWxu',
Expand All @@ -204,7 +204,7 @@ describe('The badge generator', function () {
label: 'cactus',
message: 'grown',
format: 'svg',
template: 'flat',
style: 'flat',
color: '#b3e',
labelColor: '#0f0',
links: ['https://shields.io/', 'https://www.google.co.uk/'],
Expand All @@ -218,7 +218,7 @@ describe('The badge generator', function () {
label: 'cactus',
message: 'grown',
format: 'svg',
template: 'flat-square',
style: 'flat-square',
color: '#b3e',
labelColor: '#0f0',
})
Expand All @@ -229,7 +229,7 @@ describe('The badge generator', function () {
label: 'cactus',
message: 'grown',
format: 'svg',
template: 'flat-square',
style: 'flat-square',
color: '#b3e',
labelColor: '#0f0',
logo: 'data:image/svg+xml;base64,PHN2ZyB4bWxu',
Expand All @@ -241,7 +241,7 @@ describe('The badge generator', function () {
label: '',
message: 'grown',
format: 'svg',
template: 'flat-square',
style: 'flat-square',
color: '#b3e',
})
})
Expand All @@ -251,7 +251,7 @@ describe('The badge generator', function () {
label: '',
message: 'grown',
format: 'svg',
template: 'flat-square',
style: 'flat-square',
color: '#b3e',
logo: 'data:image/svg+xml;base64,PHN2ZyB4bWxu',
})
Expand All @@ -262,7 +262,7 @@ describe('The badge generator', function () {
label: '',
message: 'grown',
format: 'svg',
template: 'flat-square',
style: 'flat-square',
color: '#b3e',
labelColor: '#0f0',
logo: 'data:image/svg+xml;base64,PHN2ZyB4bWxu',
Expand All @@ -274,7 +274,7 @@ describe('The badge generator', function () {
label: 'cactus',
message: 'grown',
format: 'svg',
template: 'flat-square',
style: 'flat-square',
color: '#b3e',
labelColor: '#0f0',
links: ['https://shields.io/', 'https://www.google.co.uk/'],
Expand All @@ -288,7 +288,7 @@ describe('The badge generator', function () {
label: 'cactus',
message: 'grown',
format: 'svg',
template: 'plastic',
style: 'plastic',
color: '#b3e',
labelColor: '#0f0',
})
Expand All @@ -299,7 +299,7 @@ describe('The badge generator', function () {
label: 'cactus',
message: 'grown',
format: 'svg',
template: 'plastic',
style: 'plastic',
color: '#b3e',
labelColor: '#0f0',
logo: 'data:image/svg+xml;base64,PHN2ZyB4bWxu',
Expand All @@ -311,7 +311,7 @@ describe('The badge generator', function () {
label: '',
message: 'grown',
format: 'svg',
template: 'plastic',
style: 'plastic',
color: '#b3e',
})
})
Expand All @@ -321,7 +321,7 @@ describe('The badge generator', function () {
label: '',
message: 'grown',
format: 'svg',
template: 'plastic',
style: 'plastic',
color: '#b3e',
logo: 'data:image/svg+xml;base64,PHN2ZyB4bWxu',
})
Expand All @@ -332,7 +332,7 @@ describe('The badge generator', function () {
label: '',
message: 'grown',
format: 'svg',
template: 'plastic',
style: 'plastic',
color: '#b3e',
labelColor: '#0f0',
logo: 'data:image/svg+xml;base64,PHN2ZyB4bWxu',
Expand All @@ -344,7 +344,7 @@ describe('The badge generator', function () {
label: 'cactus',
message: 'grown',
format: 'svg',
template: 'plastic',
style: 'plastic',
color: '#b3e',
labelColor: '#0f0',
links: ['https://shields.io/', 'https://www.google.co.uk/'],
Expand All @@ -360,7 +360,7 @@ describe('The badge generator', function () {
label: 1998,
message: 1999,
format: 'svg',
template: 'for-the-badge',
style: 'for-the-badge',
})
)
.to.include('1998')
Expand All @@ -373,7 +373,7 @@ describe('The badge generator', function () {
label: 'Label',
message: '1 string',
format: 'svg',
template: 'for-the-badge',
style: 'for-the-badge',
})
)
.to.include('LABEL')
Expand All @@ -385,7 +385,7 @@ describe('The badge generator', function () {
label: 'cactus',
message: 'grown',
format: 'svg',
template: 'for-the-badge',
style: 'for-the-badge',
color: '#b3e',
labelColor: '#0f0',
})
Expand All @@ -396,7 +396,7 @@ describe('The badge generator', function () {
label: 'cactus',
message: 'grown',
format: 'svg',
template: 'for-the-badge',
style: 'for-the-badge',
color: '#b3e',
labelColor: '#0f0',
logo: 'data:image/svg+xml;base64,PHN2ZyB4bWxu',
Expand All @@ -408,7 +408,7 @@ describe('The badge generator', function () {
label: '',
message: 'grown',
format: 'svg',
template: 'for-the-badge',
style: 'for-the-badge',
color: '#b3e',
})
})
Expand All @@ -418,7 +418,7 @@ describe('The badge generator', function () {
label: '',
message: 'grown',
format: 'svg',
template: 'for-the-badge',
style: 'for-the-badge',
color: '#b3e',
logo: 'data:image/svg+xml;base64,PHN2ZyB4bWxu',
})
Expand All @@ -429,7 +429,7 @@ describe('The badge generator', function () {
label: '',
message: 'grown',
format: 'svg',
template: 'for-the-badge',
style: 'for-the-badge',
color: '#b3e',
labelColor: '#0f0',
logo: 'data:image/svg+xml;base64,PHN2ZyB4bWxu',
Expand All @@ -441,7 +441,7 @@ describe('The badge generator', function () {
label: 'cactus',
message: 'grown',
format: 'svg',
template: 'for-the-badge',
style: 'for-the-badge',
color: '#b3e',
labelColor: '#0f0',
links: ['https://shields.io/', 'https://www.google.co.uk/'],
Expand All @@ -456,7 +456,7 @@ describe('The badge generator', function () {
label: 'some-key',
message: 'some-value',
format: 'svg',
template: 'social',
style: 'social',
})
)
.to.include('Some-key')
Expand All @@ -470,7 +470,7 @@ describe('The badge generator', function () {
label: '',
message: 'some-value',
format: 'json',
template: 'social',
style: 'social',
})
)
.to.include('""')
Expand All @@ -482,7 +482,7 @@ describe('The badge generator', function () {
label: 'cactus',
message: 'grown',
format: 'svg',
template: 'social',
style: 'social',
color: '#b3e',
labelColor: '#0f0',
})
Expand All @@ -493,7 +493,7 @@ describe('The badge generator', function () {
label: 'cactus',
message: 'grown',
format: 'svg',
template: 'social',
style: 'social',
color: '#b3e',
labelColor: '#0f0',
logo: 'data:image/svg+xml;base64,PHN2ZyB4bWxu',
Expand All @@ -505,7 +505,7 @@ describe('The badge generator', function () {
label: '',
message: 'grown',
format: 'svg',
template: 'social',
style: 'social',
color: '#b3e',
})
})
Expand All @@ -515,7 +515,7 @@ describe('The badge generator', function () {
label: '',
message: 'grown',
format: 'svg',
template: 'social',
style: 'social',
color: '#b3e',
logo: 'data:image/svg+xml;base64,PHN2ZyB4bWxu',
})
Expand All @@ -526,7 +526,7 @@ describe('The badge generator', function () {
label: '',
message: 'grown',
format: 'svg',
template: 'social',
style: 'social',
color: '#b3e',
labelColor: '#0f0',
logo: 'data:image/svg+xml;base64,PHN2ZyB4bWxu',
Expand All @@ -538,7 +538,7 @@ describe('The badge generator', function () {
label: 'cactus',
message: 'grown',
format: 'svg',
template: 'social',
style: 'social',
color: '#b3e',
labelColor: '#0f0',
links: ['https://shields.io/', 'https://www.google.co.uk/'],
Expand All @@ -563,7 +563,7 @@ describe('The badge generator', function () {
label: 'cactus',
message: 'grown',
format: 'svg',
template: 'flat',
style: 'flat',
color: '#000',
labelColor: '#f3f3f3',
})
Expand All @@ -574,7 +574,7 @@ describe('The badge generator', function () {
label: 'cactus',
message: 'grown',
format: 'svg',
template: 'for-the-badge',
style: 'for-the-badge',
color: '#e2ffe1',
labelColor: '#000',
})
Expand Down
2 changes: 1 addition & 1 deletion core/base-service/base.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ describe('BaseService', function () {
label: 'cat',
message: 'Hello namedParamA: bar with queryParamA: ?',
color: 'lightgrey',
template: 'flat',
style: 'flat',
namedLogo: undefined,
logo: undefined,
logoWidth: undefined,
Expand Down
2 changes: 1 addition & 1 deletion core/base-service/coalesce-badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ module.exports = function coalesceBadge(
serviceLabelColor,
defaultLabelColor
),
template: style,
style,
namedLogo,
logo: logoSvgBase64,
logoWidth,
Expand Down
Loading

0 comments on commit f1a5dd9

Please sign in to comment.