Add tests for setPropertyString

This commit is contained in:
Ben Woo 2025-01-10 19:48:42 +08:00
parent 68717d592c
commit 34ea244e82
3 changed files with 22 additions and 3 deletions

View File

@ -61,7 +61,7 @@ class WorldConfigTest : TestWithMockBukkit() {
assertTrue(worldConfig.stringPropertyHandle.setProperty("alias", "abc").isSuccess)
assertEquals("abc", worldConfig.stringPropertyHandle.getProperty("alias").get())
assertTrue(worldConfig.stringPropertyHandle.setProperty("scale", "2.0").isSuccess)
assertTrue(worldConfig.stringPropertyHandle.setProperty("scale", 2.0).isSuccess)
assertEquals(2.0, worldConfig.stringPropertyHandle.getProperty("scale").get())
val blacklists = listOf("a", "b", "c")
@ -72,6 +72,25 @@ class WorldConfigTest : TestWithMockBukkit() {
assertEquals(Material.JUNGLE_WOOD, worldConfig.stringPropertyHandle.getProperty("entryfee-currency").get())
}
@Test
fun `Updating an existing world property with setPropertyString reflects the changes in getProperty`() {
assertTrue(worldConfig.stringPropertyHandle.setPropertyString("adjust-spawn", "true").isSuccess)
assertEquals(true, worldConfig.stringPropertyHandle.getProperty("adjust-spawn").get())
assertTrue(worldConfig.stringPropertyHandle.setPropertyString("alias", "abc").isSuccess)
assertEquals("abc", worldConfig.stringPropertyHandle.getProperty("alias").get())
assertTrue(worldConfig.stringPropertyHandle.setPropertyString("scale", "2.0").isSuccess)
assertEquals(2.0, worldConfig.stringPropertyHandle.getProperty("scale").get())
assertTrue(worldConfig.stringPropertyHandle.setPropertyString("world-blacklist", "a,b,c").isSuccess)
assertEquals(listOf("a", "b", "c"), worldConfig.stringPropertyHandle.getProperty("world-blacklist").get())
assertTrue(worldConfig.stringPropertyHandle.setPropertyString("entryfee-currency", "jungle_wood").isSuccess)
assertEquals(Material.JUNGLE_WOOD, worldConfig.stringPropertyHandle.getProperty("entryfee-currency").get())
}
@Test
fun `Updating a non-existing property with setProperty returns false`() {
assertTrue(worldConfig.stringPropertyHandle.setProperty("invalid-property", false).isFailure)

View File

@ -22,7 +22,7 @@ world_nether:
portal-form: ALL
pvp: true
respawn-world: ''
scale: 1.0
scale: 8.0
seed: -9223372036854775808
spawn-location:
==: MVNullLocation (It's a bug if you see this in your config file)

View File

@ -61,7 +61,7 @@ world_nether:
portal-form: ALL
pvp: true
respawn-world: ''
scale: 1.0
scale: 8.0
seed: -9223372036854775808
spawn-location:
==: MVNullLocation (It's a bug if you see this in your config file)