[waffle] colorB fixes & test added (#1110)

Close #1008
This commit is contained in:
Ritwick Dey
2017-09-29 22:19:46 +05:30
committed by Paul Melnikow
parent 47ba81a007
commit 79174d4cfc
3 changed files with 55 additions and 1 deletions

View File

@@ -96,4 +96,5 @@ module.exports = {
makeLabel,
makeLogo,
makeBadgeData,
makeColor
};

View File

@@ -65,6 +65,7 @@ const {
getAnalytics
} = require('./lib/analytics');
const {
makeColor,
isValidStyle,
isSixHex: sixHex,
makeLabel: getLabel,
@@ -6129,7 +6130,7 @@ cache(function(data, match, sendBadge, request) {
badgeData.text[0] = data.label || ghLabel;
badgeData.text[1] = '' + count;
badgeData.colorscheme = null;
badgeData.colorB = '#' + (color || '78bdf2');
badgeData.colorB = makeColor(data.colorB || color || '78bdf2');
sendBadge(format, badgeData);
} catch(e) {
badgeData.text[1] = 'invalid';

52
service-tests/waffle.js Normal file
View File

@@ -0,0 +1,52 @@
const Joi = require('joi');
const ServiceTester = require('./runner/service-tester');
const t = new ServiceTester({ id: 'waffle', title: 'Waffle.io' });
module.exports = t;
const fakeData = [
{
githubMetadata: {
labels: [
{ color: "c5def5", name: "feature" },
{ color: "fbca04", name: "bug" },
{ color: "e11d21", name: "bug" }
]
}
},
{
githubMetadata: {
labels: [
{ color: "c5def5", name: "feature" },
{ color: "fbca04", name: "bug" },
{ color: "e11d21", name: "feature" }
]
}
},
{
githubMetadata: {
labels: [
{ color: "c5def5", name: "bug" },
{ color: "fbca04", name: "bug" }
]
}
},
];
t.create('label should be `bug` & value should be exactly 5 as supplied in `fakeData`. e.g: bug|5')
.get('/label/userName/repoName/bug.json')
.intercept(nock => nock('https://api.waffle.io/')
.get('/userName/repoName/cards')
.reply(200, fakeData))
.expectJSONTypes(Joi.object().keys({
name: Joi.equal('bug'),
value: Joi.equal('5')
}));
t.create('label should be `Mybug` & value should be formated. e.g: Mybug|25')
.get('/label/ritwickdey/vscode-live-server/bug.json?label=Mybug')
.expectJSONTypes(Joi.object().keys({
name: Joi.equal('Mybug'),
value: Joi.string().regex(/^\d+$/)
}));