-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DisplayNameCMDTest and TurnToPlayerCMDTest
- Loading branch information
1 parent
97c6550
commit 7368045
Showing
3 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/main/java/de/oliver/fancynpcs/tests/impl/commands/DisplayNameCMDTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package de.oliver.fancynpcs.tests.impl.commands; | ||
|
||
import de.oliver.fancynpcs.FancyNpcs; | ||
import de.oliver.fancynpcs.api.Npc; | ||
import de.oliver.fancynpcs.tests.annotations.FNAfterEach; | ||
import de.oliver.fancynpcs.tests.annotations.FNBeforeEach; | ||
import de.oliver.fancynpcs.tests.annotations.FNTest; | ||
import de.oliver.fancynpcs.tests.impl.api.NpcTestEnv; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.util.List; | ||
|
||
import static de.oliver.fancynpcs.tests.Expectable.expect; | ||
|
||
public class DisplayNameCMDTest { | ||
|
||
private Npc npc; | ||
private String npcName; | ||
|
||
@FNBeforeEach | ||
public void setUp(Player player) { | ||
npc = NpcTestEnv.givenDefaultNpcIsCreated(); | ||
npcName = npc.getData().getName(); | ||
|
||
NpcTestEnv.givenNpcIsRegistered(npc); | ||
} | ||
|
||
@FNAfterEach | ||
public void tearDown(Player player) { | ||
NpcTestEnv.givenNpcIsUnregistered(npc); | ||
|
||
npc = null; | ||
npcName = null; | ||
} | ||
|
||
@FNTest(name = "Set display name") | ||
public void setDisplayName(Player player) { | ||
String displayName = "<red>Test <orange>Display Name"; | ||
expect(player.performCommand("npc displayname " + npcName + " " + displayName)).toBe(true); | ||
expect(npc.getData().getDisplayName()).toEqual(displayName); | ||
} | ||
|
||
@FNTest(name = "Set display name to none") | ||
public void setDisplayNameToNone(Player player) { | ||
expect(player.performCommand("npc displayname " + npcName + " @none")).toBe(true); | ||
expect(npc.getData().getDisplayName()).toEqual("<empty>"); | ||
} | ||
|
||
@FNTest(name = "Set display name to empty") | ||
public void setDisplayNameToEmpty(Player player) { | ||
expect(player.performCommand("npc displayname " + npcName + " <empty>")).toBe(true); | ||
expect(npc.getData().getDisplayName()).toEqual("<empty>"); | ||
} | ||
|
||
@FNTest(name = "Set display name with blocked command") | ||
public void setDisplayNameWithBlockedCommand(Player player) { | ||
List<String> blockedCommands = FancyNpcs.getInstance().getFancyNpcConfig().getBlockedCommands(); | ||
if (blockedCommands.isEmpty()) { | ||
return; | ||
} | ||
String blockedCommand = blockedCommands.get(0); | ||
|
||
expect(player.performCommand("npc displayname " + npcName + " <click:run_command:'/" + blockedCommand + "'>hello</click>")).toBe(true); | ||
|
||
expect(npc.getData().getDisplayName()).toEqual(npcName); | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/de/oliver/fancynpcs/tests/impl/commands/TurnToPlayerCMDTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package de.oliver.fancynpcs.tests.impl.commands; | ||
|
||
import de.oliver.fancynpcs.api.Npc; | ||
import de.oliver.fancynpcs.tests.annotations.FNAfterEach; | ||
import de.oliver.fancynpcs.tests.annotations.FNBeforeEach; | ||
import de.oliver.fancynpcs.tests.annotations.FNTest; | ||
import de.oliver.fancynpcs.tests.impl.api.NpcTestEnv; | ||
import org.bukkit.entity.Player; | ||
|
||
import static de.oliver.fancynpcs.tests.Expectable.expect; | ||
|
||
public class TurnToPlayerCMDTest { | ||
|
||
private Npc npc; | ||
private String npcName; | ||
|
||
@FNBeforeEach | ||
public void setUp(Player player) { | ||
npc = NpcTestEnv.givenDefaultNpcIsCreated(); | ||
npcName = npc.getData().getName(); | ||
|
||
NpcTestEnv.givenNpcIsRegistered(npc); | ||
} | ||
|
||
@FNAfterEach | ||
public void tearDown(Player player) { | ||
NpcTestEnv.givenNpcIsUnregistered(npc); | ||
|
||
npc = null; | ||
npcName = null; | ||
} | ||
|
||
@FNTest(name = "Set turnToPlayer to true") | ||
public void setTurnToPlayerToTrue(Player player) { | ||
expect(player.performCommand("npc turn_to_player " + npcName + " true")).toBe(true); | ||
expect(npc.getData().isTurnToPlayer()).toBe(true); | ||
} | ||
|
||
@FNTest(name = "Set turnToPlayer to false") | ||
public void setTurnToPlayerToFalse(Player player) { | ||
npc.getData().setTurnToPlayer(true); | ||
|
||
expect(player.performCommand("npc turn_to_player " + npcName + " false")).toBe(true); | ||
expect(npc.getData().isTurnToPlayer()).toBe(false); | ||
} | ||
|
||
} |