fix(navigation): preserve disabled preference
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package games.dmg.spigotbase;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -21,4 +22,18 @@ final class BaseNavigationProgressionTest {
|
||||
assertTrue(update.player().navigationEnabled());
|
||||
assertTrue(update.unlockedBaseLevel());
|
||||
}
|
||||
|
||||
@Test
|
||||
void laterProgressPreservesDisabledNavigationPreference() {
|
||||
BaseProgressionService service =
|
||||
new BaseProgressionService(PluginSettings.from(Map.of()));
|
||||
PlayerState player = PlayerState.newPlayer(UUID.randomUUID(), "Alex")
|
||||
.withGrassAndDirtProgress(500, 2)
|
||||
.withNavigationEnabled(false);
|
||||
|
||||
ProgressionUpdate update = service.recordGrassOrDirtBreak(player);
|
||||
|
||||
assertFalse(update.player().navigationEnabled());
|
||||
assertFalse(update.unlockedBaseLevel());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package games.dmg.spigotbase;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
final class NavigationPreferenceTest {
|
||||
@Test
|
||||
void noArgumentTogglesCurrentPreference() {
|
||||
assertFalse(NavigationPreference.resolve(true, new String[0]));
|
||||
assertTrue(NavigationPreference.resolve(false, new String[0]));
|
||||
}
|
||||
|
||||
@Test
|
||||
void explicitModesAreIdempotent() {
|
||||
assertTrue(NavigationPreference.resolve(true, new String[] {"on"}));
|
||||
assertTrue(NavigationPreference.resolve(false, new String[] {"on"}));
|
||||
assertFalse(NavigationPreference.resolve(true, new String[] {"off"}));
|
||||
assertFalse(NavigationPreference.resolve(false, new String[] {"off"}));
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsUnknownOrExtraArguments() {
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> NavigationPreference.resolve(false, new String[] {"maybe"})
|
||||
);
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> NavigationPreference.resolve(false, new String[] {"on", "off"})
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user