Skip to content

Commit

Permalink
Call chat event in JUnit Test
Browse files Browse the repository at this point in the history
  • Loading branch information
Phill310 committed Jun 28, 2024
1 parent 591eaf9 commit d6c49ca
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,30 @@
package org.skriptlang.skript.test.tests.syntaxes.expressions;

import ch.njol.skript.test.runner.SkriptJUnitTest;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Test;

import java.util.Set;

public class ExprMessageTest extends SkriptJUnitTest {

private Player testPlayer;

static {
setShutdownDelay(1);
}

@Before
public void setup() {
testPlayer = EasyMock.niceMock(Player.class);
}

@Test
public void test() {
testPlayer.chat("hi");
Bukkit.getServer().getPluginManager().callEvent(new AsyncPlayerChatEvent(false, testPlayer, "hi", Set.of(testPlayer)));
}
}
16 changes: 8 additions & 8 deletions src/test/skript/junit/ExprMessage.sk
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ test "ExprMessageJUnit" when running JUnit:

on chat:
set {_test} to "org.skriptlang.skript.test.tests.syntaxes.expressions.ExprMessageTest"
junit test is {_test}
junit test is {_test}

set chat message to "hello"
if message is "hello":
complete objective "set message" for {_test}
set message to "hello"
if message is "hello":
complete objective "set message" for {_test}

clear message
if message is not set:
complete objective "clear message" for {_test}
clear message
if message is "":
complete objective "clear message" for {_test}

complete objective "message test complete" for {_test}
complete objective "message test complete" for {_test}

0 comments on commit d6c49ca

Please sign in to comment.