Skip to content

Commit

Permalink
improves size checking tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ivoberger committed Sep 14, 2019
1 parent f9c75d5 commit 8e0d0cb
Showing 1 changed file with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import io.kotlintest.specs.StringSpec

class Downscale : StringSpec({

"Size should stay the same as it is withing limits" {
"Size should stay the same as it is within limits" {
var origSize = 300 to 170
val url = StatikGMapsUrl("placeholder") {
size = origSize
Expand All @@ -27,6 +27,26 @@ class Downscale : StringSpec({
url.size shouldBe origSize
}

"Disallowing downscale should not result in an exception when size is within limits" {
var origSize = 300 to 170
val url = StatikGMapsUrl("placeholder") {
size = origSize
center = Location(.0, .0)
zoom = 14
downscale = false
}
url.toString()
url.size shouldBe origSize

origSize = 700 to 170
url.apply {
size = origSize
premiumPlan = true
}.toString()

url.size shouldBe origSize
}

"IllegalArgumentException should be thrown as size exceeds limits but downscaling is forbidden" {
val url = StatikGMapsUrl("placeholder") {
center = Location(address = "London")
Expand All @@ -40,12 +60,12 @@ class Downscale : StringSpec({
}
shouldThrow<IllegalArgumentException> { url.toString() }
url.apply {
size = 1000 to 1025
size = 500 to 1030
scale = 2
}
shouldThrow<IllegalArgumentException> { url.toString() }
url.apply {
size = 513 to 170
size = 500 to 600
scale = 4
}
shouldThrow<IllegalArgumentException> { url.toString() }
Expand Down

0 comments on commit 8e0d0cb

Please sign in to comment.