-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add optional class validations and fix exclude option
- Loading branch information
1 parent
fb2bfd0
commit f37814b
Showing
3 changed files
with
40 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
(ns logseq.graph-validator.validations.class | ||
"Validations related to managing classes" | ||
(:require [clojure.test :refer [deftest is]] | ||
[logseq.graph-validator.state :as state] | ||
[logseq.db.rules :as rules] | ||
[datascript.core :as d])) | ||
|
||
(defn- get-classes [] | ||
(->> (d/q | ||
'[:find (pull ?b [*]) | ||
:in $ % | ||
:where (page-property ?b :type "Class")] | ||
@state/db-conn | ||
(vals rules/query-dsl-rules)) | ||
(map first) | ||
(map #(assoc (:block/properties %) :block/original-name (:block/original-name %))))) | ||
|
||
(deftest classes-have-parents | ||
(is (empty? (remove #(or (some? (:parent %)) (= "Thing" (:block/original-name %))) | ||
(get-classes))) | ||
"All classes have parent property except Thing")) | ||
|
||
(deftest classes-have-urls | ||
(is (empty? (remove :url (get-classes))) | ||
"All classes have urls")) | ||
|
||
(deftest classes-are-capitalized | ||
(is (empty? (remove #(re-find #"^[A-Z]" (:block/original-name %)) (get-classes))) | ||
"All classes start with a capital letter")) |