forked from sduduzog/slim-launcher
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get Junit5 tests working for DataSourceModule
- Loading branch information
Showing
3 changed files
with
59 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
app/src/test/java/com/jkuester/unlauncher/datasource/DataSourceModuleTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.jkuester.unlauncher.datasource | ||
|
||
import android.content.Context | ||
import androidx.datastore.core.DataStore | ||
import com.jkuester.unlauncher.datastore.CorePreferences | ||
import com.jkuester.unlauncher.datastore.QuickButtonPreferences | ||
import com.jkuester.unlauncher.datastore.UnlauncherApps | ||
import io.mockk.every | ||
import io.mockk.impl.annotations.MockK | ||
import io.mockk.junit5.MockKExtension | ||
import io.mockk.verify | ||
import org.junit.jupiter.api.AfterEach | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.assertInstanceOf | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
|
||
@MockKExtension.CheckUnnecessaryStub | ||
@MockKExtension.ConfirmVerification | ||
@ExtendWith(MockKExtension::class) | ||
class DataSourceModuleTest { | ||
private val dataStoreModule = DataStoreModule() | ||
|
||
@MockK | ||
lateinit var appContext: Context | ||
|
||
@BeforeEach | ||
fun beforeEach() { | ||
every { appContext.applicationContext } returns appContext | ||
} | ||
|
||
@AfterEach | ||
fun afterEach() { | ||
verify { appContext.applicationContext } | ||
} | ||
|
||
@Test | ||
fun provideQuickButtonPreferencesStore() { | ||
val actualStore = dataStoreModule.provideQuickButtonPreferencesStore(appContext) | ||
assertInstanceOf<DataStore<QuickButtonPreferences>>(actualStore) | ||
} | ||
|
||
@Test | ||
fun provideUnlauncherAppsStore() { | ||
val actualStore = dataStoreModule.provideUnlauncherAppsStore(appContext) | ||
assertInstanceOf<DataStore<UnlauncherApps>>(actualStore) | ||
} | ||
|
||
@Test | ||
fun provideCorePreferencesStore() { | ||
val actualStore = dataStoreModule.provideCorePreferencesStore(appContext) | ||
assertInstanceOf<DataStore<CorePreferences>>(actualStore) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters