Extended usage of build-status.js tomore services (#2763)
* Extended usage of build-status.js * Removed remaining status arguments
This commit is contained in:
@@ -2,12 +2,22 @@
|
||||
|
||||
const Joi = require('joi')
|
||||
|
||||
const happyStatuses = ['passed', 'passing', 'success']
|
||||
const greenStatuses = [
|
||||
'fixed',
|
||||
'passed',
|
||||
'passing',
|
||||
'succeeded',
|
||||
'success',
|
||||
'successful',
|
||||
]
|
||||
|
||||
const unhappyStatuses = ['error', 'failed', 'failing', 'unstable']
|
||||
const orangeStatuses = ['partially succeeded', 'unstable', 'timeout']
|
||||
|
||||
const redStatuses = ['error', 'failed', 'failing']
|
||||
|
||||
const otherStatuses = [
|
||||
'building',
|
||||
'canceled',
|
||||
'cancelled',
|
||||
'expired',
|
||||
'no tests',
|
||||
@@ -20,21 +30,25 @@ const otherStatuses = [
|
||||
'scheduled',
|
||||
'skipped',
|
||||
'stopped',
|
||||
'timeout',
|
||||
'waiting',
|
||||
]
|
||||
|
||||
const isBuildStatus = Joi.equal(
|
||||
happyStatuses.concat(unhappyStatuses).concat(otherStatuses)
|
||||
greenStatuses
|
||||
.concat(orangeStatuses)
|
||||
.concat(redStatuses)
|
||||
.concat(otherStatuses)
|
||||
)
|
||||
|
||||
function renderBuildStatusBadge({ label, status }) {
|
||||
let message
|
||||
let color
|
||||
if (happyStatuses.includes(status)) {
|
||||
if (greenStatuses.includes(status)) {
|
||||
message = 'passing'
|
||||
color = 'brightgreen'
|
||||
} else if (unhappyStatuses.includes(status)) {
|
||||
} else if (orangeStatuses.includes(status)) {
|
||||
color = 'orange'
|
||||
} else if (redStatuses.includes(status)) {
|
||||
message = status === 'failed' ? 'failing' : status
|
||||
color = 'red'
|
||||
} else {
|
||||
|
||||
@@ -29,26 +29,37 @@ test(renderBuildStatusBadge, () => {
|
||||
|
||||
test(renderBuildStatusBadge, () => {
|
||||
forCases([
|
||||
given({ status: 'fixed' }),
|
||||
given({ status: 'passed' }),
|
||||
given({ status: 'passing' }),
|
||||
given({ status: 'succeeded' }),
|
||||
given({ status: 'success' }),
|
||||
given({ status: 'successful' }),
|
||||
]).assert('should be brightgreen', b =>
|
||||
expect(b).to.include({ color: 'brightgreen' })
|
||||
)
|
||||
})
|
||||
|
||||
test(renderBuildStatusBadge, () => {
|
||||
forCases([
|
||||
given({ status: 'partially succeeded' }),
|
||||
given({ status: 'timeout' }),
|
||||
given({ status: 'unstable' }),
|
||||
]).assert('should be orange', b => expect(b).to.include({ color: 'orange' }))
|
||||
})
|
||||
|
||||
test(renderBuildStatusBadge, () => {
|
||||
forCases([
|
||||
given({ status: 'error' }),
|
||||
given({ status: 'failed' }),
|
||||
given({ status: 'failing' }),
|
||||
given({ status: 'unstable' }),
|
||||
]).assert('should be red', b => expect(b).to.include({ color: 'red' }))
|
||||
})
|
||||
|
||||
test(renderBuildStatusBadge, () => {
|
||||
forCases([
|
||||
given({ status: 'building' }),
|
||||
given({ status: 'canceled' }),
|
||||
given({ status: 'cancelled' }),
|
||||
given({ status: 'expired' }),
|
||||
given({ status: 'no tests' }),
|
||||
@@ -61,7 +72,6 @@ test(renderBuildStatusBadge, () => {
|
||||
given({ status: 'scheduled' }),
|
||||
given({ status: 'skipped' }),
|
||||
given({ status: 'stopped' }),
|
||||
given({ status: 'timeout' }),
|
||||
given({ status: 'waiting' }),
|
||||
]).assert('should have undefined color', b =>
|
||||
expect(b).to.include({ color: undefined })
|
||||
|
||||
Reference in New Issue
Block a user