Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,6 @@ class DeckPickerViewModel :
}

/** Disables the shortcut of the deck and the children belonging to it.*/
@NeedsTest("ensure collapsed decks are also deleted")
fun disableDeckAndChildrenShortcuts(deckId: DeckId) =
launchCatchingIO {
val deckTreeDids = dueTree?.find(deckId)?.map { it.did.toString() } ?: emptyList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import org.hamcrest.Matchers.equalTo
import org.junit.Test
import org.junit.runner.RunWith
import timber.log.Timber
import kotlin.test.assertEquals

/** Test of [DeckPickerViewModel] */
@RunWith(AndroidJUnit4::class)
Expand Down Expand Up @@ -183,4 +184,28 @@ class DeckPickerViewModelTest : RobolectricTest() {
companion object {
private const val EXPECTED_CARDS: Int = 3
}

@Test
fun `ensure collapsed decks are also deleted`() {
runTest {
val deckIdA = addDeck("A")
val subDeckIdA1 = addDeck("A::A1")
val subDeckIdA2 = addDeck("A::A2")
// add other decks as well as control
addDeck("B")
addDeck("B:B1")
viewModel.flowOfDisableShortcuts.test {
viewModel.reloadDeckCounts().join()
viewModel.disableDeckAndChildrenShortcuts(deckIdA)
val actual = awaitItem()
val expected =
listOf(
deckIdA.toString(),
subDeckIdA1.toString(),
subDeckIdA2.toString(),
)
assertEquals(expected, actual)
}
}
}
}
Loading