Skip to content

Commit fd772fb

Browse files
committed
Fix the failing unit test
1 parent cc750b5 commit fd772fb

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

app/src/test/java/com/duckduckgo/app/tabs/ui/TabSwitcherViewModelTest.kt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,12 @@ class TabSwitcherViewModelTest {
106106

107107
private lateinit var testee: TabSwitcherViewModel
108108

109+
private val tabList = listOf(TabEntity("1", position = 1), TabEntity("2", position = 2))
109110
private val repoDeletableTabs = Channel<List<TabEntity>>()
110-
private val tabs = MutableLiveData<List<TabEntity>>()
111+
private val tabs = MutableLiveData<List<TabEntity>>(tabList)
111112

112113
private val tabSwitcherData = TabSwitcherData(NEW, GRID)
113-
private val flowTabs = flowOf(listOf(TabEntity("1", position = 1), TabEntity("2", position = 2)))
114+
private val flowTabs = flowOf(tabList)
114115

115116
@Before
116117
fun before() {
@@ -268,16 +269,13 @@ class TabSwitcherViewModelTest {
268269

269270
@Test
270271
fun whenOnCloseAllTabsConfirmedThenTabDeletedAndTabIdClearedAndSessionDeletedAndPixelFired() = runTest {
271-
val tab = TabEntity("ID", position = 0)
272-
tabs.value = listOf(tab)
273-
274272
testee.tabSwitcherItems.blockingObserve()
275273

276274
testee.onCloseAllTabsConfirmed()
277275

278-
verify(mockTabRepository).delete(tab)
279-
verify(mockAdClickManager).clearTabId(tab.tabId)
280-
verify(mockWebViewSessionStorage).deleteSession(tab.tabId)
276+
verify(mockTabRepository).delete(tabList.first())
277+
verify(mockAdClickManager).clearTabId(tabList.first().tabId)
278+
verify(mockWebViewSessionStorage).deleteSession(tabList.first().tabId)
281279
verify(mockPixel).fire(AppPixelName.TAB_MANAGER_MENU_CLOSE_ALL_TABS_CONFIRMED)
282280
}
283281

0 commit comments

Comments
 (0)