diff --git a/src/main/java/com/jenkinsci/plugins/badge/action/AbstractBadgeAction.java b/src/main/java/com/jenkinsci/plugins/badge/action/AbstractBadgeAction.java index 2b6b8a8..c233996 100644 --- a/src/main/java/com/jenkinsci/plugins/badge/action/AbstractBadgeAction.java +++ b/src/main/java/com/jenkinsci/plugins/badge/action/AbstractBadgeAction.java @@ -257,9 +257,9 @@ public static String getJenkinsColorStyle(@NonNull String color) { case "text": case "error": case "warning": + case "success": case "destructive": case "build": - case "success": case "danger": case "info": return "var(--" + color + "-color)"; diff --git a/src/test/java/com/jenkinsci/plugins/badge/dsl/LegacyPipelineTest.java b/src/test/java/com/jenkinsci/plugins/badge/dsl/LegacyPipelineTest.java index 3497c38..f4e84fc 100644 --- a/src/test/java/com/jenkinsci/plugins/badge/dsl/LegacyPipelineTest.java +++ b/src/test/java/com/jenkinsci/plugins/badge/dsl/LegacyPipelineTest.java @@ -47,21 +47,35 @@ class LegacyPipelineTest { @Test - void color(JenkinsRule r) throws Exception { - Stream> palette = Stream.of( - "blue", "brown", "cyan", "green", "indigo", "orange", "pink", "purple", "red", "yellow", - "white", "black") - .map(c -> Arrays.asList("'" + c + "'", "color: var(--" + c + ");")); - Stream> semantic = Stream.of( - "accent", "text", "error", "warning", "success", "destructive", "build", "danger", "info") - .map(c -> Arrays.asList("'" + c + "'", "color: var(--" + c + "-color);")); + void color(JenkinsRule r) { + List colors = Arrays.asList( + "blue", "brown", "cyan", "green", "indigo", "orange", "pink", "purple", "red", "yellow", "white", + "black"); + Stream> palette = + colors.stream().map(c -> Arrays.asList("'" + c + "'", "color: var(--" + c + ");")); + Stream> paletteLight = + colors.stream().map(c -> Arrays.asList("'light-" + c + "'", "color: var(--light-" + c + ");")); + Stream> paletteDark = + colors.stream().map(c -> Arrays.asList("'dark-" + c + "'", "color: var(--dark-" + c + ");")); + + List semantics = Arrays.asList( + "accent", "text", "error", "warning", "success", "destructive", "build", "danger", "info"); + Stream> semantic = + semantics.stream().map(c -> Arrays.asList("'" + c + "'", "color: var(--" + c + "-color);")); + Stream> other = Stream.of( + Arrays.asList("'light-'", "color: light-;"), + Arrays.asList("'dark-'", "color: dark-;"), Arrays.asList("'#ff0000'", "color: #ff0000;"), Arrays.asList("'tortoise'", "color: tortoise;"), Arrays.asList("'jenkins-!-color-red'", "color: var(--red);"), Arrays.asList("'jenkins-!-warning-color'", "color: var(--warning-color);"), + Arrays.asList("''", "color: ;"), Arrays.asList("null", null)); + assertAll("palette", colorTests(r, palette)); + assertAll("palette-light", colorTests(r, paletteLight)); + assertAll("palette-dark", colorTests(r, paletteDark)); assertAll("semantic", colorTests(r, semantic)); assertAll("other", colorTests(r, other)); }