Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a few tests to increase code coverage #143

Merged
merged 1 commit into from
May 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.jenkinsci.plugins.badge.action;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;

import hudson.model.Hudson;
Expand Down Expand Up @@ -37,6 +38,8 @@ void getIconClass(@SuppressWarnings("unused") JenkinsRule r) {
assertEquals("icon-sm jenkins-!-color-blue", action.getIconClass());
action = BadgeAction.createBadge("/foo/symbol-star.gif", "blue", "", null);
assertEquals("jenkins-!-color-blue", action.getIconClass());
action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "jenkins-!-color-red", "", null);
assertEquals("icon-sm jenkins-!-color-red", action.getIconClass());
// teal is not in the palette
action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "teal", "", null);
assertEquals("icon-sm", action.getIconClass());
Expand All @@ -57,4 +60,31 @@ void getIconColorStyle(@SuppressWarnings("unused") JenkinsRule r) {
action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "teal", "", null);
assertEquals("teal", action.getIconColorStyle());
}

@Test
void createInfoBadge(@SuppressWarnings("unused") JenkinsRule r) {
BadgeAction action = BadgeAction.createInfoBadge("This is an info badge");
assertNull(action.getIconFileName());
assertFalse(action.isTextOnly());
assertEquals("", action.getDisplayName());
assertEquals("", action.getUrlName());
}

@Test
void createWarningBadge(@SuppressWarnings("unused") JenkinsRule r) {
BadgeAction action = BadgeAction.createInfoBadge("This is a warning badge");
assertNull(action.getIconFileName());
assertFalse(action.isTextOnly());
assertEquals("", action.getDisplayName());
assertEquals("", action.getUrlName());
}

@Test
void createErrorBadge(@SuppressWarnings("unused") JenkinsRule r) {
BadgeAction action = BadgeAction.createErrorBadge("This is an error badge");
assertNull(action.getIconFileName());
assertFalse(action.isTextOnly());
assertEquals("", action.getDisplayName());
assertEquals("", action.getUrlName());
}
}