Skip to content

Commit

Permalink
Elevate coverage in common module
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanarodr committed May 5, 2024
1 parent f472596 commit e1b7d31
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,41 @@
package br.com.stonks.common.formatters

import org.junit.Assert.assertEquals
import org.junit.Test
import kotlin.test.assertEquals

class CurrencyFormatterTest {

private val delta = 0.0

@Test
fun `given currency formatter then return value with parametrized locale`() {
val result = 16.00.formatCurrency()

assertEquals("R\$ 16,00", result)
}

@Test
fun `given currency formatter when convert invalid value then return default zero`() {
assertEquals(0.0, "lorem".toCurrency(), delta)
}

@Test
fun `given currency formatter when convert with partially invalid value then return only numbers`() {
assertEquals(0.14, "14B".toCurrency(), delta)
}

@Test
fun `given currency formatter when convert value with symbol then return currency value`() {
assertEquals(0.14, "R$ 0,14".toCurrency(), delta)
}

@Test
fun `given currency formatter when convert value with format numbers then return currency value`() {
assertEquals(0.14, "0,14".toCurrency(), delta)
}

@Test
fun `given currency formatter when convert value with only numbers then return currency value`() {
assertEquals(0.14, "14".toCurrency(), delta)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import java.util.Date

class DateFormatterTest {

private val currentDate = Date(2024, 4, 3)

@Test
fun `given date formatter then return value with parametrized pattern`() {
val result = Date().formatTo(DatePattern.DATE_PATTERN_DD_MMMM_BR)
val result = currentDate.formatTo(DatePattern.DATE_PATTERN_DD_MMMM_BR)

assertEquals("03 de maio", result)
}
Expand Down
9 changes: 4 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ gradle-doctor = "0.9.2"
gradle-dependency-analysis = "1.31.0"
gradle-dependency-guard = "0.5.0"
gradle-graph-assertion = "2.5.0"
gradle-build-parameters = '1.4.4'

# kotlin
kotlin = "1.9.23"
Expand All @@ -28,7 +27,7 @@ androidx-swiperefresh-layout = "1.1.0"
androidx-lifecycle = "2.7.0"
androidx-startup-runtime = "1.1.1"
androidx-compose-bom = "2024.04.01"
androidx-compose-compiler = "1.5.11" # 1.5.12
androidx-compose-compiler = "1.5.12"
androidx-compose-runtime-tracing = "1.0.0-beta01"
androidx-compose-test = "1.6.6"
androidx-room = "2.6.1"
Expand All @@ -38,7 +37,6 @@ androidx-navigation-runtime = "2.7.7"
# square
retrofit = "2.11.0"
okhttp = "4.12.0"
leakcanary = "2.14"

# 3rd tools
timber = "5.0.1"
Expand All @@ -62,6 +60,7 @@ androidx-truth-ext = "1.5.0"
junit = "4.13.2"
truth = "1.4.2"
mockk = "1.13.10"
turbine = "1.1.0"

[libraries]

Expand Down Expand Up @@ -114,7 +113,6 @@ retrofit-converter = { group = "com.squareup.retrofit2", name = "converter-gson"
okhttp-bom = { group = "com.squareup.okhttp3", name = "okhttp-bom", version.ref = "okhttp" }
okhttp-core = { group = "com.squareup.okhttp3", name = "okhttp" }
okhttp-logging = { group = "com.squareup.okhttp3", name = "logging-interceptor" }
leakcanary = { group = "com.squareup.leakcanary", name = "leakcanary-android", version.ref = "leakcanary" }

# 3rd tools
timber = { group = "com.jakewharton.timber", name = "timber", version.ref = "timber" }
Expand Down Expand Up @@ -146,6 +144,7 @@ mockk-agent = { group = "io.mockk", name = "mockk-agent", version.ref = "mockk"}
koin-test-core = { group = "io.insert-koin", name = "koin-test" }
koin-test-junit4 = { group = "io.insert-koin", name = "koin-test-junit4" }
koin-android-test = { group = "io.insert-koin", name = "koin-android-test" }
turbine = { group = "app.cash.turbine", name = "turbine", version.ref = "turbine" }

# lint
detekt-gradlePlugin = { group = "io.gitlab.arturbosch.detekt", name = "detekt-gradle-plugin", version.ref = "detekt-core" }
Expand All @@ -162,6 +161,7 @@ test-jvm = [
"kotlinx-coroutines-test",
"koin-test-core",
"koin-test-junit4",
"turbine"
]

test-android = [
Expand All @@ -183,7 +183,6 @@ gradle-doctor = { id = "com.osacky.doctor", version.ref = "gradle-doctor" }
gradle-dependency-analysis = { id = "com.autonomousapps.dependency-analysis", version.ref = "gradle-dependency-analysis" }
gradle-dependency-guard = { id = "com.dropbox.dependency-guard", version.ref = "gradle-dependency-guard" }
gradle-graph-assertion = { id = "com.jraska.module.graph.assertion", version.ref = "gradle-graph-assertion" }
gradle-build-parameters = { id = "org.gradlex.build-parameters", version.ref = "gradle-build-parameters" }
android-application = { id = "com.android.application", version.ref = "android-gradle-plugin" }
android-library = { id = "com.android.library", version.ref = "android-gradle-plugin" }
android-test = { id = "com.android.test", version.ref = "android-gradle-plugin" }
Expand Down

0 comments on commit e1b7d31

Please sign in to comment.