diff --git a/game/src/plugins/logout/meta.toml b/game/src/plugins/logout/meta.toml new file mode 100644 index 00000000..574c74b3 --- /dev/null +++ b/game/src/plugins/logout/meta.toml @@ -0,0 +1 @@ +name = "logout" \ No newline at end of file diff --git a/game/src/plugins/logout/src/logout.plugin.kts b/game/src/plugins/logout/src/logout.plugin.kts new file mode 100644 index 00000000..e3bf59ef --- /dev/null +++ b/game/src/plugins/logout/src/logout.plugin.kts @@ -0,0 +1,5 @@ +val LOGOUT_BUTTON_ID = 2458 + +on_button(LOGOUT_BUTTON_ID) + .where { widgetId == LOGOUT_BUTTON_ID } + .then { it.logout() } \ No newline at end of file diff --git a/game/src/plugins/logout/test/LogoutTests.kt b/game/src/plugins/logout/test/LogoutTests.kt new file mode 100644 index 00000000..e974c135 --- /dev/null +++ b/game/src/plugins/logout/test/LogoutTests.kt @@ -0,0 +1,19 @@ +import org.apollo.game.message.impl.ButtonMessage +import org.apollo.game.plugin.testing.KotlinPluginTest +import org.junit.Test +import org.mockito.Mockito.times +import org.mockito.Mockito.verify + +class LogoutTests : KotlinPluginTest() { + + companion object { + const val LOGOUT_BUTTON_ID = 2458 + } + + @Test fun `The player should be logged out when they click the logout button`() { + player.notify(ButtonMessage(LOGOUT_BUTTON_ID)) + + verify(player, times(1)).logout() + } + +} \ No newline at end of file