parent
3a88e89a80
commit
f51206e417
1 changed files with 16 additions and 14 deletions
|
@ -8,11 +8,12 @@ import app.aaps.plugins.automation.elements.InputCarePortalMenu
|
|||
import app.aaps.plugins.automation.elements.InputDuration
|
||||
import app.aaps.plugins.automation.elements.InputString
|
||||
import io.reactivex.rxjava3.core.Single
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.mockito.ArgumentMatchers
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.skyscreamer.jsonassert.JSONAssert
|
||||
|
||||
class ActionCarePortalEventTest : ActionsTestBase() {
|
||||
|
||||
|
@ -35,41 +36,42 @@ class ActionCarePortalEventTest : ActionsTestBase() {
|
|||
}
|
||||
|
||||
@Test fun friendlyNameTest() {
|
||||
Assertions.assertEquals(app.aaps.core.ui.R.string.careportal, sut.friendlyName())
|
||||
assertThat(sut.friendlyName()).isEqualTo(app.aaps.core.ui.R.string.careportal)
|
||||
}
|
||||
|
||||
@Test fun shortDescriptionTest() {
|
||||
Assertions.assertEquals("Note : Asd", sut.shortDescription())
|
||||
assertThat(sut.shortDescription()).isEqualTo("Note : Asd")
|
||||
}
|
||||
|
||||
@Test fun iconTest() {
|
||||
Assertions.assertEquals(app.aaps.core.main.R.drawable.ic_cp_note, sut.icon())
|
||||
assertThat(sut.icon()).isEqualTo(app.aaps.core.main.R.drawable.ic_cp_note)
|
||||
}
|
||||
|
||||
@Test fun doActionTest() {
|
||||
sut.doAction(object : Callback() {
|
||||
override fun run() {
|
||||
Assertions.assertTrue(result.success)
|
||||
assertThat(result.success).isTrue()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@Test fun hasDialogTest() {
|
||||
Assertions.assertTrue(sut.hasDialog())
|
||||
assertThat(sut.hasDialog()).isTrue()
|
||||
}
|
||||
|
||||
@Test fun toJSONTest() {
|
||||
Assertions.assertEquals(
|
||||
"{\"data\":{\"note\":\"Asd\",\"cpEvent\":\"NOTE\",\"durationInMinutes\":5},\"type\":\"ActionCarePortalEvent\"}",
|
||||
sut.toJSON()
|
||||
JSONAssert.assertEquals(
|
||||
"""{"data":{"note":"Asd","cpEvent":"NOTE","durationInMinutes":5},"type":"ActionCarePortalEvent"}""",
|
||||
sut.toJSON(),
|
||||
true,
|
||||
)
|
||||
}
|
||||
|
||||
@Test fun fromJSONTest() {
|
||||
sut.note = InputString("Asd")
|
||||
sut.fromJSON("{\"note\":\"Asd\",\"cpEvent\":\"NOTE\",\"durationInMinutes\":5}")
|
||||
Assertions.assertEquals("Asd", sut.note.value)
|
||||
Assertions.assertEquals(5, sut.duration.value)
|
||||
Assertions.assertEquals(InputCarePortalMenu.EventType.NOTE, sut.cpEvent.value)
|
||||
sut.fromJSON("""{"note":"Asd","cpEvent":"NOTE","durationInMinutes":5}""")
|
||||
assertThat(sut.note.value).isEqualTo("Asd")
|
||||
assertThat(sut.duration.value).isEqualTo(5)
|
||||
assertThat(sut.cpEvent.value).isEqualTo(InputCarePortalMenu.EventType.NOTE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue