fix [GitHubHacktoberfest] service test (#4299)

* tests: fix hacktoberfest service test

* tests: update message for post-hacktoberfest, add couple unit tests

* chore: lgtm fix

* tests: fix unit test
This commit is contained in:
Caleb Cartwright
2019-11-06 04:47:56 -06:00
committed by GitHub
parent 18d63aec6e
commit 5a4f705e8f
4 changed files with 46 additions and 6 deletions

View File

@@ -3,15 +3,27 @@
const Joi = require('@hapi/joi')
const t = (module.exports = require('../tester').createServiceTester())
const isHactoberfestCombinedStatus = Joi.string().regex(
const isHacktoberfestNoIssuesStatus = Joi.string().regex(
/^[0-9]+ PRs?(, [0-9]+ days? left)?$/
)
const isHacktoberfestNoPRsStatus = Joi.string().regex(
/^([0-9]+ open issues?)?[0-9]+ days? left$/
)
const isHacktoberfestCombinedStatus = Joi.string().regex(
/^[0-9]+ open issues?(, [0-9]+ PRs?)?(, [0-9]+ days? left)?$/
)
const isHacktoberfestStatus = Joi.alternatives().try(
isHacktoberfestNoIssuesStatus,
isHacktoberfestNoPRsStatus,
isHacktoberfestCombinedStatus,
/^is over! \([0-9]+ PRs? opened\)$/
)
t.create('GitHub Hacktoberfest combined status')
.get('/badges/shields.json')
.expectBadge({
label: 'hacktoberfest',
message: isHactoberfestCombinedStatus,
message: isHacktoberfestStatus,
})
t.create('GitHub Hacktoberfest combined status (suggestion label override)')
@@ -22,5 +34,5 @@ t.create('GitHub Hacktoberfest combined status (suggestion label override)')
)
.expectBadge({
label: 'hacktoberfest',
message: isHactoberfestCombinedStatus,
message: isHacktoberfestStatus,
})