aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChloe Kudryavtsev <code@toast.bunkerlabs.net>2023-04-10 13:49:16 -0400
committerChloe Kudryavtsev <code@toast.bunkerlabs.net>2023-04-10 13:49:16 -0400
commitadf046b0cbac93f4d3c090f7cd28f63b5add7fec (patch)
treeac46c801c3ccfadf76dd12490601eceef6bb77cb /test
parentmeta: prepare for 1.2.0 release (diff)
janet: improve query handling, add part-appending
also tests
Diffstat (limited to 'test')
-rw-r--r--test/03-api/03-fields/append-path.janet9
-rw-r--r--test/03-api/03-fields/query.janet16
2 files changed, 25 insertions, 0 deletions
diff --git a/test/03-api/03-fields/append-path.janet b/test/03-api/03-fields/append-path.janet
new file mode 100644
index 0000000..a79443a
--- /dev/null
+++ b/test/03-api/03-fields/append-path.janet
@@ -0,0 +1,9 @@
+(use ../../../jurl)
+
+(def base (http :get "https://pie.dev/status"))
+(defn- check-code
+ [code]
+ (def out ((append-path (string code) base)))
+ (assert (out :status) code) code)
+(loop [code :range [200 210]]
+ (check-code code))
diff --git a/test/03-api/03-fields/query.janet b/test/03-api/03-fields/query.janet
new file mode 100644
index 0000000..2a82b05
--- /dev/null
+++ b/test/03-api/03-fields/query.janet
@@ -0,0 +1,16 @@
+(use ../../../jurl)
+(import spork/json)
+
+(defn test
+ [url queries expect]
+ (def r ((->> url
+ (http :get)
+ (query queries))))
+ (assert (= 200 (r :status)))
+ (def j (json/decode (r :body) true))
+ (def c (freeze (j :args)))
+ (assert (= c expect)))
+
+(test "https://pie.dev/get" {:a :b} {:a "b"})
+(test "https://pie.dev/get?c=d" {:a :b} {:a "b" :c "d"})
+(test "https://pie.dev/get?a=b" {:a :c} {:a ["b" "c"]})