block_test.cljs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. (ns logseq.graph-parser.block-test
  2. (:require [logseq.graph-parser.block :as gp-block]
  3. [cljs.test :refer [deftest are]]))
  4. (deftest test-extract-properties
  5. (are [x y] (= (:properties (gp-block/extract-properties :markdown x {})) y)
  6. [["year" "1000"]] {:year 1000}
  7. [["year" "\"1000\""]] {:year "\"1000\""}
  8. [["background-color" "#000000"]] {:background-color "#000000"}
  9. [["alias" "name/with space"]] {:alias #{"name/with space"}}
  10. [["year" "1000"] ["alias" "name/with space"]] {:year 1000, :alias #{"name/with space"}}
  11. [["year" "1000"] ["tags" "name/with space"]] {:year 1000, :tags #{"name/with space"}}
  12. [["year" "1000"] ["tags" "name/with space, another"]] {:year 1000, :tags #{"name/with space" "another"}}
  13. [["year" "1000"] ["alias" "name/with space, another"]] {:year 1000, :alias #{"name/with space" "another"}}
  14. [["year" "1000"] ["alias" "name/with space, [[another [[nested]]]]"]] {:year 1000, :alias #{"name/with space" "another [[nested]]"}}
  15. [["year" "1000"] ["alias" "name/with space, [[[[nested]] another]]"]] {:year 1000, :alias #{"name/with space" "[[nested]] another"}}
  16. [["foo" "bar"]] {:foo "bar"}
  17. [["foo" "bar, baz"]] {:foo #{"bar" "baz"}}
  18. [["foo" "bar, [[baz]]"]] {:foo #{"bar" "baz"}}
  19. [["foo" "[[bar]], [[baz]]"]] {:foo #{"bar" "baz"}}
  20. [["foo" "[[bar]], [[nested [[baz]]]]"]] {:foo #{"bar" "nested [[baz]]"}}
  21. [["foo" "[[bar]], [[nested [[baz]]]]"]] {:foo #{"bar" "nested [[baz]]"}}
  22. [["foo" "bar, [[baz, test]]"]] {:foo #{"bar" "baz, test"}}
  23. [["foo" "bar, [[baz, test, [[nested]]]]"]] {:foo #{"bar" "baz, test, [[nested]]"}}
  24. [["file-path" "file:///home/x, y.pdf"]] {:file-path "file:///home/x, y.pdf"})
  25. (are [x y] (= (vec (:page-refs (gp-block/extract-properties :markdown x {}))) y)
  26. [["year" "1000"]] []
  27. [["year" "\"1000\""]] []
  28. [["foo" "[[bar]] test"]] ["bar" "test"]
  29. [["foo" "[[bar]] test [[baz]]"]] ["bar" "test" "baz"]
  30. [["foo" "[[bar]] test [[baz]] [[nested [[baz]]]]"]] ["bar" "test" "baz" "nested [[baz]]"]
  31. [["foo" "#bar, #baz"]] ["bar" "baz"]
  32. [["foo" "[[nested [[page]]]], test"]] ["nested [[page]]" "test"]))
  33. #_(cljs.test/run-tests)