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'
|
||||
if (status !== 'finished' && status !== '') {
|
||||
return {
|
||||
|
||||
@@ -14,6 +14,7 @@ const {
|
||||
silverMockResponse,
|
||||
bronzeMockResponse,
|
||||
noMedalMockResponse,
|
||||
noGradeMockResponse,
|
||||
criticalViolation,
|
||||
majorViolation,
|
||||
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({
|
||||
description: 'critical violations',
|
||||
response: criticalViolation,
|
||||
|
||||
@@ -38,6 +38,7 @@ const bronzeMockResponse = createMockResponse({
|
||||
const noMedalMockResponse = createMockResponse({
|
||||
grade: 'none',
|
||||
})
|
||||
const noGradeMockResponse = createMockResponse({})
|
||||
const criticalViolation = createMockResponse({
|
||||
violations: [
|
||||
{
|
||||
@@ -106,6 +107,7 @@ module.exports = {
|
||||
silverMockResponse,
|
||||
bronzeMockResponse,
|
||||
noMedalMockResponse,
|
||||
noGradeMockResponse,
|
||||
criticalViolation,
|
||||
majorViolation,
|
||||
minorViolation,
|
||||
|
||||
Reference in New Issue
Block a user