Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rfc2822 committed Dec 12, 2024
1 parent 5b6c124 commit 6bc7238
Showing 1 changed file with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import dagger.hilt.android.testing.HiltAndroidTest
import io.mockk.MockKAnnotations
import io.mockk.every
import io.mockk.impl.annotations.InjectMockKs
import io.mockk.impl.annotations.MockK
import io.mockk.impl.annotations.RelaxedMockK
import io.mockk.impl.annotations.SpyK
import io.mockk.just
Expand Down Expand Up @@ -48,28 +47,34 @@ class LocalAddressBookStoreTest {
@SpyK
lateinit var context: Context

val account: Account = mockk(relaxed = true)
val account: Account = Account("MrRobert@example.com", "Mock Account Type")
val provider = mockk<ContentProviderClient>(relaxed = true)
val addressBook: LocalAddressBook = mockk(relaxed = true) {
every { updateSyncFrameworkSettings() } just runs
every { addressBookAccount } returns account
every { settings } returns LocalAddressBookStore.contactsProviderSettings
}

@MockK
@RelaxedMockK
lateinit var collectionRepository: DavCollectionRepository

@MockK
lateinit var localAddressBookFactory: LocalAddressBook.Factory
val localAddressBookFactory = mockk<LocalAddressBook.Factory> {
every { create(account, provider) } returns addressBook
}

@RelaxedMockK
@Inject
@SpyK
lateinit var logger: Logger

@RelaxedMockK
lateinit var settingsManager: SettingsManager

@MockK
lateinit var serviceRepository: DavServiceRepository
val serviceRepository = mockk<DavServiceRepository>(relaxed = true) {
every { get(any<Long>()) } returns null
every { get(200) } returns mockk<Service> {
every { accountName } returns "MrRobert@example.com"
}
}

@InjectMockKs
@SpyK
Expand All @@ -82,12 +87,6 @@ class LocalAddressBookStoreTest {

// initialize global mocks
MockKAnnotations.init(this)
every { localAddressBookFactory.create(account, provider) } returns addressBook

every { serviceRepository.get(any<Long>()) } returns null
every { serviceRepository.get(200) } returns mockk<Service> {
every { accountName } returns "MrRobert@example.com"
}
}

@After
Expand Down

0 comments on commit 6bc7238

Please sign in to comment.