aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorAleksandr <ognelisar@gmail.com>2018-03-12 17:32:25 +0700
committerAleksandr <ognelisar@gmail.com>2018-03-12 17:32:25 +0700
commit04a21e9a5ab46f885cb51626d274d570fefe4a29 (patch)
tree862c9b8702c4f9f9410b85d09107cc73d5355c5a /src/test
parent1ea8a5c1298edae003f5d4d8c4b9e8581d834b04 (diff)
parent96aa1fbf7608e3b9cd1ba06c57ab1f356409733d (diff)
downloaddriver-core-04a21e9a5ab46f885cb51626d274d570fefe4a29.tar.gz
driver-core-04a21e9a5ab46f885cb51626d274d570fefe4a29.tar.bz2
driver-core-04a21e9a5ab46f885cb51626d274d570fefe4a29.zip
Merge branch 'master' into TM-1431
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/xyz/driver/core/rest/RestTest.scala23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/scala/xyz/driver/core/rest/RestTest.scala b/src/test/scala/xyz/driver/core/rest/RestTest.scala
index d36e04d..68fe419 100644
--- a/src/test/scala/xyz/driver/core/rest/RestTest.scala
+++ b/src/test/scala/xyz/driver/core/rest/RestTest.scala
@@ -47,4 +47,27 @@ class RestTest extends WordSpec with Matchers with ScalatestRouteTest with Direc
}
}
}
+
+ "optional paginated directive" should {
+ val route: Route = rest.optionalPagination { paginated =>
+ complete(StatusCodes.OK -> paginated.map(p => s"${p.pageNumber},${p.pageSize}").getOrElse("no pagination"))
+ }
+ "accept a pagination" in {
+ Get("/?pageNumber=2&pageSize=42") ~> route ~> check {
+ assert(status == StatusCodes.OK)
+ assert(entityAs[String] == "2,42")
+ }
+ }
+ "without pagination" in {
+ Get("/") ~> route ~> check {
+ assert(status == StatusCodes.OK)
+ assert(entityAs[String] == "no pagination")
+ }
+ }
+ "reject an invalid pagination" in {
+ Get("/?pageNumber=1") ~> route ~> check {
+ assert(rejection.isInstanceOf[ValidationRejection])
+ }
+ }
+ }
}