Skip to content

Commit

Permalink
Change JVM and JS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomiej.zylinski committed May 23, 2024
1 parent 4ce8510 commit 9497cbc
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 265 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ class UriTests extends AnyFunSuite with Matchers with TryValues {
List(QS.Plain("ą/ę&+;?", encoding = QuerySegmentEncoding.Relaxed)) -> "%C4%85/%C4%99&+;?",
List(QS.KeyValue("k", "v1,v2", valueEncoding = QuerySegmentEncoding.All)) -> "k=v1%2Cv2",
List(QS.KeyValue("k", "v1-v2", valueEncoding = QuerySegmentEncoding.All)) -> "k=v1-v2",
List(QS.KeyValue("k", "v1~v2", valueEncoding = QuerySegmentEncoding.All)) -> "k=v1~v2",
List(QS.KeyValue("k", "v1_v2", valueEncoding = QuerySegmentEncoding.All)) -> "k=v1_v2",
List(QS.KeyValue("k", "v1.v2", valueEncoding = QuerySegmentEncoding.All)) -> "k=v1.v2",
List(QS.KeyValue("k", "v1,v2")) -> "k=v1,v2",
Expand Down
25 changes: 25 additions & 0 deletions core/src/test/scalajs/sttp/model/UriTestsHelper.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package sttp.model

import org.scalatest.TryValues
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
import sttp.model.Uri._

class UriTestsHelper extends AnyFunSuite with Matchers with TryValues {

val QS = QuerySegment

val testUri = Uri.unsafeApply("http", None, "example.com", None, Nil, Nil, None)

val querySegmentsTestData = List(
List(QS.KeyValue("k", "v1~v2", valueEncoding = QuerySegmentEncoding.All)) -> "k=v1~v2"
)

for {
(segments, expected) <- querySegmentsTestData
} {
test(s"$segments should serialize to$expected") {
testUri.copy(querySegments = segments).toString should endWith(expected)
}
}
}
264 changes: 0 additions & 264 deletions core/src/test/scalajvm/sttp/model/UriTests.scala

This file was deleted.

25 changes: 25 additions & 0 deletions core/src/test/scalajvm/sttp/model/UriTestsHelper.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package sttp.model

import org.scalatest.TryValues
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
import sttp.model.Uri._

class UriTestsHelper extends AnyFunSuite with Matchers with TryValues {

val QS = QuerySegment

val testUri = Uri.unsafeApply("http", None, "example.com", None, Nil, Nil, None)

val querySegmentsTestData = List(
List(QS.KeyValue("k", "v1~v2", valueEncoding = QuerySegmentEncoding.All)) -> "k=v1%7Ev2"
)

for {
(segments, expected) <- querySegmentsTestData
} {
test(s"$segments should serialize to$expected") {
testUri.copy(querySegments = segments).toString should endWith(expected)
}
}
}

0 comments on commit 9497cbc

Please sign in to comment.