File tree Expand file tree Collapse file tree
main/java/com/ichi2/anki/deckpicker
test/java/com/ichi2/anki/deckpicker Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -460,7 +460,6 @@ class DeckPickerViewModel :
460460 }
461461
462462 /* * Disables the shortcut of the deck and the children belonging to it.*/
463- @NeedsTest(" ensure collapsed decks are also deleted" )
464463 fun disableDeckAndChildrenShortcuts (deckId : DeckId ) =
465464 launchCatchingIO {
466465 val deckTreeDids = dueTree?.find(deckId)?.map { it.did.toString() } ? : emptyList()
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ import org.hamcrest.Matchers.equalTo
3535import org.junit.Test
3636import org.junit.runner.RunWith
3737import timber.log.Timber
38+ import kotlin.test.assertEquals
3839
3940/* * Test of [DeckPickerViewModel] */
4041@RunWith(AndroidJUnit4 ::class )
@@ -183,4 +184,28 @@ class DeckPickerViewModelTest : RobolectricTest() {
183184 companion object {
184185 private const val EXPECTED_CARDS : Int = 3
185186 }
187+
188+ @Test
189+ fun `ensure collapsed decks are also deleted` () {
190+ runTest {
191+ val deckIdA = addDeck(" A" )
192+ val subDeckIdA1 = addDeck(" A::A1" )
193+ val subDeckIdA2 = addDeck(" A::A2" )
194+ // add other decks as well as control
195+ addDeck(" B" )
196+ addDeck(" B:B1" )
197+ viewModel.flowOfDisableShortcuts.test {
198+ viewModel.reloadDeckCounts().join()
199+ viewModel.disableDeckAndChildrenShortcuts(deckIdA)
200+ val actual = awaitItem()
201+ val expected =
202+ listOf (
203+ deckIdA.toString(),
204+ subDeckIdA1.toString(),
205+ subDeckIdA2.toString(),
206+ )
207+ assertEquals(expected, actual)
208+ }
209+ }
210+ }
186211}
You can’t perform that action at this time.
0 commit comments