Skip to content

Commit

Permalink
Merge pull request #381 from hossain-khan/add-tests
Browse files Browse the repository at this point in the history
[ADDED] Tests
  • Loading branch information
hossain-khan authored Dec 24, 2024
2 parents 816ad4c + f80e0f2 commit 3789aa1
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/test/kotlin/dev/hossain/time/DurationExtensionKtTest.kt
Original file line number Diff line number Diff line change
@@ -1,34 +1,29 @@
package dev.hossain.time

import com.google.common.truth.Truth.assertThat
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import kotlin.time.Duration

/**
* Contains unit tests for [DurationExtension].
* Contains unit tests for [Duration] extensions.
*/
class DurationExtensionKtTest {
@BeforeEach
fun setUp() {
}
@Test
fun `toWorkingHour - given duration less than working hours - returns same duration`() {
val duration: Duration = "2h".duration()

@AfterEach
fun tearDown() {
}
val result = duration.toWorkingHour()

@Test
fun toWorkingHour() {
assertThat(result).isEqualTo("2h")
}

@Test
fun `toWorkingHour - given duration less than working hours - returns same duration`() {
val duration = "2h".duration()
fun `toWorkingHour - given duration less than working hours - returns same duration with min`() {
val duration = "2h 32m".duration()

val result = duration.toWorkingHour()

assertThat(result).isEqualTo("2h")
assertThat(result).isEqualTo("2h 32m")
}

@Test
Expand Down Expand Up @@ -58,6 +53,15 @@ class DurationExtensionKtTest {
assertThat(result).isEqualTo("2 days [Based on 8h on a working day]")
}

@Test
fun `toWorkingHour - given duration equal to two working days - returns two days and hours and mins`() {
val duration = "18h 48m".duration()

val result = duration.toWorkingHour()

assertThat(result).isEqualTo("2 days and 2h 48m [Based on 8h on a working day]")
}

@Test
fun `toWorkingHour - given duration of one day - returns three days`() {
val duration = "24h".duration()
Expand Down

0 comments on commit 3789aa1

Please sign in to comment.