Skip to content

Commit

Permalink
Mark facility changed as false when facility is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
msasikanth committed Nov 22, 2023
1 parent 532f91a commit e6ce4dc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
package org.simple.clinic.facility.alertchange

sealed interface AlertFacilityChangeEvent {
import org.simple.clinic.widgets.UiEvent

sealed interface AlertFacilityChangeEvent : UiEvent {

data class IsFacilityChangedStatusLoaded(val isFacilityChanged: Boolean) : AlertFacilityChangeEvent

data object FacilityChangedMarkedAsFalse : AlertFacilityChangeEvent

data object YesButtonClicked : AlertFacilityChangeEvent
data object YesButtonClicked : AlertFacilityChangeEvent {
override val analyticsName: String = "Alert Facility Changed Sheet:Yes Button Clicked"
}

data object FacilityChanged : AlertFacilityChangeEvent
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.spotify.mobius.Next
import com.spotify.mobius.Next.next
import com.spotify.mobius.Update
import org.simple.clinic.facility.alertchange.AlertFacilityChangeEffect.MarkFacilityChangedAsFalse
import org.simple.clinic.facility.alertchange.AlertFacilityChangeEvent.FacilityChanged
import org.simple.clinic.facility.alertchange.AlertFacilityChangeEvent.FacilityChangedMarkedAsFalse
import org.simple.clinic.facility.alertchange.AlertFacilityChangeEvent.IsFacilityChangedStatusLoaded
import org.simple.clinic.facility.alertchange.AlertFacilityChangeEvent.YesButtonClicked
Expand All @@ -17,6 +18,7 @@ class AlertFacilityChangeUpdate : Update<AlertFacilityChangeModel, AlertFacility
is IsFacilityChangedStatusLoaded -> isFacilityChangeStatusLoaded(event, model)
FacilityChangedMarkedAsFalse -> dispatch(CloseSheetWithContinuation)
YesButtonClicked -> dispatch(MarkFacilityChangedAsFalse)
FacilityChanged -> dispatch(MarkFacilityChangedAsFalse)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.spotify.mobius.test.UpdateSpec
import com.spotify.mobius.test.UpdateSpec.assertThatNext
import org.junit.Test
import org.simple.clinic.facility.alertchange.AlertFacilityChangeEffect.MarkFacilityChangedAsFalse
import org.simple.clinic.facility.alertchange.AlertFacilityChangeEvent.FacilityChanged
import org.simple.clinic.facility.alertchange.AlertFacilityChangeEvent.FacilityChangedMarkedAsFalse
import org.simple.clinic.facility.alertchange.AlertFacilityChangeEvent.IsFacilityChangedStatusLoaded
import org.simple.clinic.facility.alertchange.AlertFacilityChangeEvent.YesButtonClicked
Expand Down Expand Up @@ -67,4 +68,17 @@ class AlertFacilityChangeUpdateTest {
hasEffects(CloseSheetWithContinuation)
))
}

@Test
fun `when facility is changed, then mark facility changed as false`() {
val model = defaultModel.updateIsFacilityChanged(isFacilityChanged = true)

updateSpec
.given(model)
.whenEvent(FacilityChanged)
.then(assertThatNext(
hasNoModel(),
hasEffects(MarkFacilityChangedAsFalse)
))
}
}

0 comments on commit e6ce4dc

Please sign in to comment.