Skip to content

Commit 9c8d735

Browse files
committed
Fix the failing unit test
1 parent c71a9c5 commit 9c8d735

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
@@ -101,11 +101,12 @@ class TabSwitcherViewModelTest {
101101

102102
private lateinit var testee: TabSwitcherViewModel
103103

104+
private val tabList = listOf(TabEntity("1", position = 1), TabEntity("2", position = 2))
104105
private val repoDeletableTabs = Channel<List<TabEntity>>()
105-
private val tabs = MutableLiveData<List<TabEntity>>()
106+
private val tabs = MutableLiveData<List<TabEntity>>(tabList)
106107

107108
private val tabSwitcherData = TabSwitcherData(NEW, GRID)
108-
private val flowTabs = flowOf(listOf(TabEntity("1", position = 1), TabEntity("2", position = 2)))
109+
private val flowTabs = flowOf(tabList)
109110

110111
@Before
111112
fun before() {
@@ -262,16 +263,13 @@ class TabSwitcherViewModelTest {
262263

263264
@Test
264265
fun whenOnCloseAllTabsConfirmedThenTabDeletedAndTabIdClearedAndSessionDeletedAndPixelFired() = runTest {
265-
val tab = TabEntity("ID", position = 0)
266-
tabs.value = listOf(tab)
267-
268266
testee.tabSwitcherItems.blockingObserve()
269267

270268
testee.onCloseAllTabsConfirmed()
271269

272-
verify(mockTabRepository).delete(tab)
273-
verify(mockAdClickManager).clearTabId(tab.tabId)
274-
verify(mockWebViewSessionStorage).deleteSession(tab.tabId)
270+
verify(mockTabRepository).delete(tabList.first())
271+
verify(mockAdClickManager).clearTabId(tabList.first().tabId)
272+
verify(mockWebViewSessionStorage).deleteSession(tabList.first().tabId)
275273
verify(mockPixel).fire(AppPixelName.TAB_MANAGER_MENU_CLOSE_ALL_TABS_CONFIRMED)
276274
}
277275

0 commit comments

Comments
 (0)