From a5da75d2ee2e092b726efab61cc02a910ae98140 Mon Sep 17 00:00:00 2001 From: eltrac Date: Sun, 4 Oct 2026 10:56:36 +0800 Subject: test: /api/mentions/ should not be malformed #28 --- test/weepinbell/handler_test.clj | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/weepinbell/handler_test.clj b/test/weepinbell/handler_test.clj index b718e34..15f32db 100644 --- a/test/weepinbell/handler_test.clj +++ b/test/weepinbell/handler_test.clj @@ -1,7 +1,8 @@ (ns weepinbell.handler-test (:require [clojure.test :refer [testing is deftest]] [ring.mock.request :as mock] - [weepinbell.handler :refer [app]])) + [weepinbell.handler :refer [app]] + [cheshire.core :refer [parse-string]])) (defmacro test-mention-list-by-domain-route [mftype] `(testing (str "/api/" ~mftype "/:domain route") @@ -12,18 +13,25 @@ :modified 0}}])} {}) (mock/request :get (str "/api/" ~mftype "/www.example")))] - (is (= (:status ~'response) 200))))) + (is (= (:status ~'response) 200)) + (is (some? (:body ~'response)))))) (defmacro test-mention-list-by-url-route [mftype] `(testing (str "/api/" ~mftype "?url= route") - (let [~'response ((app nil {:get-by-domain (fn [~'_] - [{:webmention {:source "" - :target "http://localhost/" - :id "" - :modified 0}}])} + (let [~'response ((app nil + {:get-by-domain + (fn [~'_] + [{:webmention {:source "https://source.net" + :target "http://localhost" + :id "123456789123456789" + :modified 0} + :microformats {:type :like-of}}])} {}) (mock/request :get (str "/api/" ~mftype "?url=http://localhost")))] - (is (= (:status ~'response) 200))))) + (is (= (:status ~'response) 200)) + (is (some? (:body ~'response))) + (when-not (-> ~'response :body parse-string empty?) + (is (-> ~'response :body parse-string first (get "webmention") some?)))))) (deftest api-routes-test (testing "homepage route" -- cgit v1.2.3