|
|
@@ -1,5 +1,5 @@
|
|
|
(ns frontend.db.query-custom-test
|
|
|
- (:require [cljs.test :refer [deftest is use-fixtures]]
|
|
|
+ (:require [cljs.test :refer [deftest is use-fixtures testing]]
|
|
|
[frontend.test.helper :as test-helper :refer [load-test-files]]
|
|
|
[frontend.db.query-custom :as query-custom]
|
|
|
[frontend.db.react :as react]))
|
|
|
@@ -21,23 +21,33 @@
|
|
|
- LATER b3
|
|
|
- b3"}])
|
|
|
|
|
|
- (is (= ["LATER b3"]
|
|
|
- (map :block/content
|
|
|
- (custom-query {:query '[:find (pull ?b [*])
|
|
|
- :where
|
|
|
- (block-content ?b "b")
|
|
|
- (task ?b #{"LATER"})]})))
|
|
|
- "datalog query returns correct results")
|
|
|
+ (testing "advanced datalog queries"
|
|
|
+ (is (= ["LATER b3"]
|
|
|
+ (map :block/content
|
|
|
+ (custom-query {:query '[:find (pull ?b [*])
|
|
|
+ :where
|
|
|
+ (block-content ?b "b")
|
|
|
+ (task ?b #{"LATER"})]})))
|
|
|
+ "basic advanced query works")
|
|
|
|
|
|
- (is (= ["LATER b3"]
|
|
|
- (map :block/content
|
|
|
- (custom-query {:query '[:find (pull ?b [*])
|
|
|
- :in $
|
|
|
- :where
|
|
|
- (block-content ?b "b")
|
|
|
- (task ?b #{"LATER"})]})))
|
|
|
- "datalog query with :in returns correct results")
|
|
|
+ (is (= ["LATER b3"]
|
|
|
+ (map :block/content
|
|
|
+ (custom-query {:query '[:find (pull ?b [*])
|
|
|
+ :in $
|
|
|
+ :where
|
|
|
+ (block-content ?b "b")
|
|
|
+ (task ?b #{"LATER"})]})))
|
|
|
+ "advanced query with an :in works")
|
|
|
|
|
|
+ (is (= #{"page1"}
|
|
|
+ (set
|
|
|
+ (map #(get-in % [:block/page :block/name])
|
|
|
+ (custom-query {:query '[:find (pull ?b [*])
|
|
|
+ :in $ ?page
|
|
|
+ :where
|
|
|
+ (page ?b ?page)]
|
|
|
+ :inputs ["page1"]}))))
|
|
|
+ "advanced query with bound :in argument works"))
|
|
|
|
|
|
(is (= ["LATER b3"]
|
|
|
(map :block/content
|