Cotton code
51 lines · 1.7 KB · KotlinRaw
package com.cottondb.android.keyboardimport androidx.test.ext.junit.runners.AndroidJUnit4import org.junit.Assert.assertEqualsimport org.junit.Testimport org.junit.runner.RunWith@RunWith(AndroidJUnit4::class)class KeyboardVisibleProblemTest {    @Test    fun storageAndInputFailuresAreVisibleWhileMissingSnapshotIsQuiet() {        assertEquals(            "Keyboard storage is unavailable.",            keyboardVisibleProblem(                KeyboardSnapshotRead.Missing,                KeyboardInputSessionError.Storage(IllegalStateException("Acorn storage")),            ),        )        assertEquals(            "The app stopped accepting input.",            keyboardVisibleProblem(                KeyboardSnapshotRead.Missing,                KeyboardInputSessionError.InputConnectionGone(IllegalStateException("Cedar editor")),            ),        )        assertEquals(null, keyboardVisibleProblem(KeyboardSnapshotRead.Missing, null))    }    @Test    fun malformedSnapshotIsVisibleWithoutInventingAWarningForValidData() {        assertEquals(            "Recent takes could not be read.",            keyboardVisibleProblem(KeyboardSnapshotRead.Malformed("wrong shape"), null),        )        assertEquals(            null,            keyboardVisibleProblem(                KeyboardSnapshotRead.Available(                    KeyboardSnapshot(                        raw = kotlinx.serialization.json.JsonObject(emptyMap()),                        asOf = null,                        settings = null,                        takes = emptyList(),                    ),                ),                null,            ),        )    }}