After the update `TestCoroutineDispatcher`, `TestCoroutineScope` and
`runBlockingTest` are deprecated.
Instead of these new `TestDispatcher`, `TestScope` and `runTest` APIs are used.
Took the oportunity to also replace most of the `runBlocking` calls with the
new `runTest` specially designed for running coroutines in tests API.
@ -761,7 +762,7 @@ class DefaultBrowserToolbarMenuControllerTest {
}
@Test
fun`GIVEN account exists and the user is not signed in WHEN sign in to sync menu item is pressed THEN navigate to account problem fragment`()=runBlockingTest {
fun`GIVEN account exists and the user is not signed in WHEN sign in to sync menu item is pressed THEN navigate to account problem fragment`()=runTest {
fun`WHEN MessageClicked THEN update storage`()= runTestOnMain{
valmessage=Message(
"control-id",
mockk(relaxed=true),
@ -115,7 +117,7 @@ class MessagingMiddlewareTest {
}
@Test
fun`WHEN MessageDismissed THEN update storage`() {
fun`WHEN MessageDismissed THEN update storage`()= runTestOnMain{
valmessage=Message(
"control-id",
mockk(relaxed=true),
@ -141,7 +143,7 @@ class MessagingMiddlewareTest {
}
@Test
fun`WHEN MessageDisplayed THEN update storage`() {
fun`WHEN MessageDisplayed THEN update storage`()= runTestOnMain{
valmessage=Message(
"control-id",
mockk(relaxed=true),
@ -169,7 +171,7 @@ class MessagingMiddlewareTest {
}
@Test
fun`WHEN onMessageDismissed THEN updateMetadata,removeMessage , UpdateMessages and removeMessageToShowIfNeeded`() {
fun`WHEN onMessageDismissed THEN updateMetadata,removeMessage , UpdateMessages and removeMessageToShowIfNeeded`()= runTestOnMain{
valmessage=Message(
"control-id",
mockk(relaxed=true),
@ -192,7 +194,7 @@ class MessagingMiddlewareTest {
}
@Test
fun`WHEN removeMessage THEN remove the message`() {
fun`WHEN removeMessage THEN remove the message`()= runTestOnMain{
valmessage=Message(
"control-id",
mockk(relaxed=true),
@ -215,7 +217,7 @@ class MessagingMiddlewareTest {
}
@Test
fun`WHEN consumeMessageToShowIfNeeded THEN consume the message`() {
fun`WHEN consumeMessageToShowIfNeeded THEN consume the message`()= runTestOnMain{
valmessage=Message(
"control-id",
mockk(relaxed=true),
@ -237,7 +239,7 @@ class MessagingMiddlewareTest {
}
@Test
fun`WHEN updateMessage THEN update available messages`() {
fun`WHEN updateMessage THEN update available messages`()= runTestOnMain{
valoldMessage=Message(
"oldMessage",
mockk(relaxed=true),
@ -276,7 +278,7 @@ class MessagingMiddlewareTest {
}
@Test
fun`GIVEN a message with that not surpassed the maxDisplayCount WHEN onMessagedDisplayed THEN update the available messages and the updateMetadata`() {
fun`GIVEN a message with that not surpassed the maxDisplayCount WHEN onMessagedDisplayed THEN update the available messages and the updateMetadata`()= runTestOnMain{
valstyle:StyleData=mockk(relaxed=true)
valoldMessageData:MessageData=mockk(relaxed=true)
valoldMessage=Message(
@ -308,7 +310,7 @@ class MessagingMiddlewareTest {
}
@Test
fun`GIVEN a message with that surpassed the maxDisplayCount WHEN onMessagedDisplayed THEN remove the message and consume it`() {
fun`GIVEN a message with that surpassed the maxDisplayCount WHEN onMessagedDisplayed THEN remove the message and consume it`()= runTestOnMain{
// Seems like the most we can test is that an update was made.
coVerify{dataStore.updateData(any())}
@ -163,7 +167,7 @@ class PocketUpdatesMiddlewareTest {
@Test
@Suppress("UNCHECKED_CAST")
fun`WHEN restoreSelectedCategories is called THEN dispatch PocketStoriesCategoriesSelectionsChange with data read from the persistence layer`() {
fun`WHEN restoreSelectedCategories is called THEN dispatch PocketStoriesCategoriesSelectionsChange with data read from the persistence layer`()= runTestOnMain{
fun`GIVEN the list of credit cards is not empty, WHEN fragment is displayed THEN the manage credit cards pref is 'Manage saved cards'`() {
fun`GIVEN the list of credit cards is not empty, WHEN fragment is displayed THEN the manage credit cards pref is 'Manage saved cards'`()= runTestOnMain{
@ -100,7 +105,7 @@ class AutofillSettingFragmentTest {
}
@Test
fun`GIVEN the list of addresses is not empty WHEN fragment is displayed THEN the manage addresses preference label is 'Manage addresses'`() {
fun`GIVEN the list of addresses is not empty WHEN fragment is displayed THEN the manage addresses preference label is 'Manage addresses'`()= runTestOnMain{
fun`GIVEN no remote wallpapers expired and locale not in promo WHEN downloading remote wallpapers THEN non-promo wallpapers downloaded`()=runBlockingTest {
fun`GIVEN no remote wallpapers expired and locale not in promo WHEN downloading remote wallpapers THEN non-promo wallpapers downloaded`()=runTest {