From 86ad2a8a32b050f1b4e1279f85d4c369883fddef Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 12 Oct 2022 20:10:35 +0100 Subject: [PATCH] fixing wrong room overview in test state --- .../kotlin/app/dapk/st/messenger/MessengerViewModelTest.kt | 6 ++++-- test-harness/src/test/kotlin/test/impl/InstantScheduler.kt | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/features/messenger/src/test/kotlin/app/dapk/st/messenger/MessengerViewModelTest.kt b/features/messenger/src/test/kotlin/app/dapk/st/messenger/MessengerViewModelTest.kt index fb8680a..fdaaadc 100644 --- a/features/messenger/src/test/kotlin/app/dapk/st/messenger/MessengerViewModelTest.kt +++ b/features/messenger/src/test/kotlin/app/dapk/st/messenger/MessengerViewModelTest.kt @@ -2,6 +2,7 @@ package app.dapk.st.messenger import ViewModelTest import app.dapk.st.core.Lce +import app.dapk.st.core.extensions.takeIfContent import app.dapk.st.engine.MessengerState import app.dapk.st.engine.RoomState import app.dapk.st.engine.SendMessage @@ -72,9 +73,10 @@ class MessengerViewModelTest { @Test fun `given composer message state when posting send text, then resets composer state and sends message`() = runViewModelTest { - fakeChatEngine.expectUnit { it.send(expectTextMessage(A_MESSAGE_CONTENT), aRoomOverview()) } + val initialState = initialStateWithComposerMessage(A_ROOM_ID, A_MESSAGE_CONTENT) + fakeChatEngine.expectUnit { it.send(expectTextMessage(A_MESSAGE_CONTENT), initialState.roomState.takeIfContent()!!.roomState.roomOverview) } - viewModel.test(initialState = initialStateWithComposerMessage(A_ROOM_ID, A_MESSAGE_CONTENT)).post(MessengerAction.ComposerSendText) + viewModel.test(initialState = initialState).post(MessengerAction.ComposerSendText) assertStates({ copy(composerState = ComposerState.Text("", reply = null)) }) verifyExpects() diff --git a/test-harness/src/test/kotlin/test/impl/InstantScheduler.kt b/test-harness/src/test/kotlin/test/impl/InstantScheduler.kt index f0d7788..2cdf443 100644 --- a/test-harness/src/test/kotlin/test/impl/InstantScheduler.kt +++ b/test-harness/src/test/kotlin/test/impl/InstantScheduler.kt @@ -12,7 +12,7 @@ class InstantScheduler(private val matrixClient: MatrixClient) : BackgroundSched matrixClient.run( MatrixTaskRunner.MatrixTask( task.type, - task.jsonPayload + task.jsonPayload.value, ) ) }