Handle missing Symfony Insight grade gracefully (#3933)
This commit is contained in:
@@ -30,7 +30,7 @@ module.exports = class SymfonyInsightGrade extends SymfonyInsightBase {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
static render({ status, grade }) {
|
static render({ status, grade = 'none' }) {
|
||||||
const label = 'grade'
|
const label = 'grade'
|
||||||
if (status !== 'finished' && status !== '') {
|
if (status !== 'finished' && status !== '') {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ const {
|
|||||||
silverMockResponse,
|
silverMockResponse,
|
||||||
bronzeMockResponse,
|
bronzeMockResponse,
|
||||||
noMedalMockResponse,
|
noMedalMockResponse,
|
||||||
|
noGradeMockResponse,
|
||||||
criticalViolation,
|
criticalViolation,
|
||||||
majorViolation,
|
majorViolation,
|
||||||
minorViolation,
|
minorViolation,
|
||||||
@@ -203,6 +204,16 @@ describe('SymfonyInsight[Grade|Stars|Violation]', function() {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
testBadges({
|
||||||
|
description: 'no medal',
|
||||||
|
response: noGradeMockResponse,
|
||||||
|
expectedGradeBadge: {
|
||||||
|
label: 'grade',
|
||||||
|
message: 'no medal',
|
||||||
|
color: 'red',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
testBadges({
|
testBadges({
|
||||||
description: 'critical violations',
|
description: 'critical violations',
|
||||||
response: criticalViolation,
|
response: criticalViolation,
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ const bronzeMockResponse = createMockResponse({
|
|||||||
const noMedalMockResponse = createMockResponse({
|
const noMedalMockResponse = createMockResponse({
|
||||||
grade: 'none',
|
grade: 'none',
|
||||||
})
|
})
|
||||||
|
const noGradeMockResponse = createMockResponse({})
|
||||||
const criticalViolation = createMockResponse({
|
const criticalViolation = createMockResponse({
|
||||||
violations: [
|
violations: [
|
||||||
{
|
{
|
||||||
@@ -106,6 +107,7 @@ module.exports = {
|
|||||||
silverMockResponse,
|
silverMockResponse,
|
||||||
bronzeMockResponse,
|
bronzeMockResponse,
|
||||||
noMedalMockResponse,
|
noMedalMockResponse,
|
||||||
|
noGradeMockResponse,
|
||||||
criticalViolation,
|
criticalViolation,
|
||||||
majorViolation,
|
majorViolation,
|
||||||
minorViolation,
|
minorViolation,
|
||||||
|
|||||||
Reference in New Issue
Block a user