Skip to content
This repository has been archived by the owner on Oct 21, 2023. It is now read-only.

Commit

Permalink
refactor: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
FunkyMuse committed Jun 21, 2021
1 parent 9814b7a commit 108b5c3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.crazylegend.vigilante.crashes

import com.crazylegend.kotlinextensions.collections.isNotNullOrEmpty
import com.crazylegend.collections.isNotNullOrEmpty
import io.mockk.MockKAnnotations
import io.mockk.every
import io.mockk.mockk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ class FakePrefsProvider : DefaultPreferences, DotContract, NotificationsContract
getDateFormat = value
}

override var isSoundEnabled: Boolean = false

override fun updateSoundValue(value: Boolean) {
isSoundEnabled = value
}

override var getDateFormat: String = "dd.MM.yyyy HH:mm:ss"
override var areNotificationsEnabled: Boolean = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import com.crazylegend.vigilante.di.providers.prefs.customization.CustomizationP
import com.crazylegend.vigilante.di.providers.prefs.customization.CustomizationPrefs.Companion.DEFAULT_DOT_SIZE
import com.crazylegend.vigilante.utils.toggleValue
import org.hamcrest.CoreMatchers.instanceOf
import org.hamcrest.MatcherAssert.assertThat
import org.junit.Assert.assertEquals
import org.junit.Assert.assertThat
import org.junit.Test
import java.text.SimpleDateFormat

Expand All @@ -15,7 +15,7 @@ import java.text.SimpleDateFormat
*/
class PrefsProviderTest {

val defaultPreferences = FakePrefsProvider()
private val defaultPreferences = FakePrefsProvider()

@Test
fun `update Date Format and get the updated date`() {
Expand All @@ -26,6 +26,11 @@ class PrefsProviderTest {
assertThat(SimpleDateFormat(dateFormat), instanceOf(SimpleDateFormat::class.java))
}

@Test
fun `notifications sound test`() {
toggleValue(initialExpectation = false, { defaultPreferences.isSoundEnabled }) { defaultPreferences.updateSoundValue(true) }
}

@Test
fun `notifications test`() {
toggleValue(initialExpectation = false, { defaultPreferences.areNotificationsEnabled }) { defaultPreferences.updateNotificationsValue(true) }
Expand Down

0 comments on commit 108b5c3

Please sign in to comment.