From 417630590a2f96beff6b2ed55b0437b721baee38 Mon Sep 17 00:00:00 2001 From: Ben Yorke Date: Wed, 18 Jan 2023 14:40:12 +0100 Subject: [PATCH] Add explicit tests for :+X-ms and :-X-ms --- src/test/frontend/db/query_react_test.cljs | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/test/frontend/db/query_react_test.cljs b/src/test/frontend/db/query_react_test.cljs index b6dede3e1..3dd83c8be 100644 --- a/src/test/frontend/db/query_react_test.cljs +++ b/src/test/frontend/db/query_react_test.cljs @@ -106,6 +106,30 @@ created-at:: %s" (inc today-timestamp) next-week-timestamp)}]) + (is (= ["today"] + (map #(-> % :block/content string/split-lines first) + (custom-query {:inputs [:-0d-ms :+0d-ms] + :query '[:find (pull ?b [*]) + :in $ ?start ?end + :where + [?b :block/content] + [?b :block/created-at ?timestamp] + [(>= ?timestamp ?start)] + [(<= ?timestamp ?end)]]}))) + ":+0d-ms and :-0d-ms resolve to correct datetime range") + + (is (= ["yesterday" "today"] + (map #(-> % :block/content string/split-lines first) + (custom-query {:inputs [:-1d-ms :+5d-ms] + :query '[:find (pull ?b [*]) + :in $ ?start ?end + :where + [?b :block/content] + [?b :block/created-at ?timestamp] + [(>= ?timestamp ?start)] + [(<= ?timestamp ?end)]]}))) + ":-Xd-ms and :+Xd-ms resolve to correct datetime range") + (is (= ["today"] (map #(-> % :block/content string/split-lines first) (custom-query {:inputs [:start-of-today-ms :end-of-today-ms]