Skip to content

Commit

Permalink
Close mozilla-mobile#21366: Fix intermittent test failure in TitleHea…
Browse files Browse the repository at this point in the history
…derBindingTest
  • Loading branch information
jonalmeida authored and mergify[bot] committed Sep 20, 2021
1 parent d4ce149 commit e9434a5
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,33 @@
package org.mozilla.fenix.tabstray.browser

import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runBlockingTest
import mozilla.components.browser.state.action.TabListAction
import mozilla.components.browser.state.state.BrowserState
import mozilla.components.browser.state.state.createTab
import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.concept.storage.HistoryMetadataKey
import mozilla.components.support.test.ext.joinBlocking
import mozilla.components.support.test.libstate.ext.waitUntilIdle
import mozilla.components.support.test.rule.MainCoroutineRule
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test

@ExperimentalCoroutinesApi
class TitleHeaderBindingTest {

@OptIn(ExperimentalCoroutinesApi::class)
@get:Rule
val coroutinesTestRule = MainCoroutineRule()

@Test
fun `WHEN normal tabs are added to the list THEN return true`() {
fun `WHEN normal tabs are added to the list THEN return true`() = runBlockingTest {
var result = false
val store = BrowserStore()
val binding = TitleHeaderBinding(store) { result = it }

store.dispatch(TabListAction.AddTabAction(createTab("https://mozilla.org")))
store.dispatch(TabListAction.AddTabAction(createTab("https://mozilla.org"))).joinBlocking()

binding.start()

Expand All @@ -39,7 +41,7 @@ class TitleHeaderBindingTest {
}

@Test
fun `WHEN grouped tabs are added to the list THEN return false`() {
fun `WHEN grouped tabs are added to the list THEN return false`() = runBlockingTest {
var result = false
val store = BrowserStore()
val binding = TitleHeaderBinding(store) { result = it }
Expand All @@ -54,7 +56,7 @@ class TitleHeaderBindingTest {
)
)
)
)
).joinBlocking()

binding.start()

Expand All @@ -64,7 +66,7 @@ class TitleHeaderBindingTest {
}

@Test
fun `WHEN normal tabs are all removed THEN return false`() {
fun `WHEN normal tabs are all removed THEN return false`() = runBlockingTest {
var result = false
val store = BrowserStore(
initialState = BrowserState(
Expand All @@ -73,7 +75,7 @@ class TitleHeaderBindingTest {
)
val binding = TitleHeaderBinding(store) { result = it }

store.dispatch(TabListAction.RemoveTabAction("123"))
store.dispatch(TabListAction.RemoveTabAction("123")).joinBlocking()

binding.start()

Expand Down

0 comments on commit e9434a5

Please sign in to comment.