-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display hours of play time only if game lasts more than one hour
- Loading branch information
Showing
3 changed files
with
36 additions
and
1 deletion.
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
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
30 changes: 30 additions & 0 deletions
30
gauguin-core/src/test/kotlin/org/piepmeyer/gauguin/UtilsTest.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,30 @@ | ||
package org.piepmeyer.gauguin | ||
|
||
import io.kotest.core.spec.style.FunSpec | ||
import io.kotest.matchers.shouldBe | ||
import kotlin.time.Duration.Companion.hours | ||
import kotlin.time.Duration.Companion.minutes | ||
import kotlin.time.Duration.Companion.seconds | ||
|
||
class UtilsTest : FunSpec({ | ||
|
||
test("duration of zero shows minutes and seconds") { | ||
Utils.displayableGameDuration(0.minutes) shouldBe "00:00" | ||
} | ||
|
||
test("duration of 61 seconds shows 1:01") { | ||
Utils.displayableGameDuration(61.seconds) shouldBe "01:01" | ||
} | ||
|
||
test("duration less than one hour does not contain hour component") { | ||
Utils.displayableGameDuration(50.minutes) shouldBe "50:00" | ||
} | ||
|
||
test("duration with more than one hour does contain hour component") { | ||
Utils.displayableGameDuration(90.minutes) shouldBe "1:30:00" | ||
} | ||
|
||
test("duration with two-digit hours does contain two-digit hour component") { | ||
Utils.displayableGameDuration(23.hours) shouldBe "23:00:00" | ||
} | ||
}) |