Skip to content

Commit

Permalink
Actually check if the negative tests do their job
Browse files Browse the repository at this point in the history
  • Loading branch information
Sfiguz7 committed Dec 12, 2023
1 parent 88ac05f commit a690f81
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,32 @@ void testEventIsFired() {
server.getPluginManager().clearEvents();
// Assert the normal talisman does not activate in the ender chest
activateAnvilTalisman(false, true);

// Try to activate the talisman in the inventory. If the catch is not hit, throw an error
boolean caught = false;
try {
activateAnvilTalisman(false, false);
server.getPluginManager().assertEventFired(TalismanActivateEvent.class, ignored -> true);
} catch (AssertionError ignored) {
return; // This is expected; the event should not have fired
caught = true;
} finally {
if (!caught) {
throw new AssertionError("TalismanActivateEvent was fired when it should not have been");
}
}
server.getPluginManager().clearEvents();

// Assert the ender talisman does not activate in the inventory
caught = false;
try {
activateAnvilTalisman(true, false);
server.getPluginManager().assertEventFired(TalismanActivateEvent.class, ignored -> true);
} catch (AssertionError ignored) {
return; // This is expected; the event should not have fired
caught = true;
} finally {
if (!caught) {
throw new AssertionError("TalismanActivateEvent was fired when it should not have been");
}
}
server.getPluginManager().clearEvents();
}
Expand Down

0 comments on commit a690f81

Please sign in to comment.