Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pajlada committed Sep 11, 2024
1 parent 3432133 commit f0517eb
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/test/java/dinkplugin/notifiers/KillCountNotifierTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,61 @@ void testIgnoreTheatreNoPb() {
verify(messageHandler, never()).createMessage(any(), anyBoolean(), any());
}

@Test
void testPrimaryWithComma() {
// more config
when(config.killCountInterval()).thenReturn(1);

// fire event
String gameMessage = "Your King Black Dragon kill count is: 1,337.";
notifier.onGameMessage(gameMessage);
notifier.onTick();

// check notification
NotificationBody<BossNotificationData> body = NotificationBody.<BossNotificationData>builder()
.text(buildTemplate("King Black Dragon", 1337))
.extra(new BossNotificationData("King Black Dragon", 1337, gameMessage, null, null))
.playerName(PLAYER_NAME)
.type(NotificationType.KILL_COUNT)
.build();

verifyCreateMessage(
PRIMARY_WEBHOOK_URL,
true,
body
);

assertDoesNotThrow(() -> RuneLiteAPI.GSON.toJson(body));
}

@Test
void testSecondaryWithComma() {
// more config
when(config.killCountInterval()).thenReturn(1);

// fire events
notifier.onGameMessage("Subdued in 6:13. Personal best: 5:57");
String gameMessage = "Your Tempoross kill count is: 1,337.";
notifier.onGameMessage(gameMessage);
notifier.onTick();

// check notification
NotificationBody<BossNotificationData> body = NotificationBody.<BossNotificationData>builder()
.text(buildTemplate("Tempoross", 1337))
.extra(new BossNotificationData("Tempoross", 1337, gameMessage, Duration.ofMinutes(6).plusSeconds(13), false))
.playerName(PLAYER_NAME)
.type(NotificationType.KILL_COUNT)
.build();

verifyCreateMessage(
PRIMARY_WEBHOOK_URL,
true,
body
);

assertDoesNotThrow(() -> RuneLiteAPI.GSON.toJson(body));
}

private static Template buildTemplate(String boss, int count) {
return Template.builder()
.template(PLAYER_NAME + " has defeated {{boss}} with a completion count of " + count)
Expand Down

0 comments on commit f0517eb

Please sign in to comment.