mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-22 18:46:45 +01:00
Add list entry variable test case to RendersTemplate.
Adds test cases that cover a some of what was changed in 6e8a3e1626
.
This commit is contained in:
parent
6e8a3e1626
commit
01b253d304
@ -6,6 +6,7 @@ import static org.mockito.Mockito.*;
|
||||
|
||||
import com.garbagemule.MobArena.framework.Arena;
|
||||
import com.garbagemule.MobArena.waves.WaveManager;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@ -94,6 +95,40 @@ public class RendersTemplateTest {
|
||||
assertThat(result, equalTo(joining));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rendersReadyListEntries() {
|
||||
Player ready = mock(Player.class);
|
||||
when(ready.getName()).thenReturn("Bobcat00");
|
||||
Player notready = mock(Player.class);
|
||||
when(notready.getName()).thenReturn("garbagemule");
|
||||
Arena arena = mock(Arena.class);
|
||||
when(arena.configName()).thenReturn("castle");
|
||||
when(arena.isRunning()).thenReturn(false);
|
||||
when(arena.getNonreadyPlayers()).thenReturn(Collections.singletonList(notready));
|
||||
when(arena.getReadyPlayersInLobby()).thenReturn(Collections.singleton(ready));
|
||||
Template template = new Template.Builder("template")
|
||||
.withBase(new String[]{"<ready-1>", "<ready-2>", "<notready-1>", "<notready-2>"})
|
||||
.build();
|
||||
|
||||
String[] result = subject.render(template, arena);
|
||||
|
||||
String[] expected = {"Bobcat00", "", "garbagemule", ""};
|
||||
assertThat(result, equalTo(expected));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doesNotRenderInvalidListEntries() {
|
||||
Arena arena = arena("castle", false, true);
|
||||
String[] base = new String[]{"<ready-0>", "<ready--1>", "<ready-n>", "<ready-999999>"};
|
||||
Template template = new Template.Builder("template")
|
||||
.withBase(base)
|
||||
.build();
|
||||
|
||||
String[] result = subject.render(template, arena);
|
||||
|
||||
assertThat(result, equalTo(base));
|
||||
}
|
||||
|
||||
private Arena arena(String name, boolean running, boolean lobby) {
|
||||
Arena arena = mock(Arena.class);
|
||||
when(arena.configName()).thenReturn(name);
|
||||
|
Loading…
Reference in New Issue
Block a user