block_test.cljs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. (ns frontend.format.block-test
  2. (:require [frontend.format.block :as block]
  3. [cljs.test :refer [deftest are]]))
  4. (deftest test-extract-properties
  5. (are [x y] (= (:properties (block/extract-properties 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. (are [x y] (= (vec (:page-refs (block/extract-properties x))) y)
  25. [["year" "1000"]] []
  26. [["year" "\"1000\""]] []
  27. [["foo" "[[bar]] test"]] ["bar" "test"]
  28. [["foo" "[[bar]] test [[baz]]"]] ["bar" "test" "baz"]
  29. [["foo" "[[bar]] test [[baz]] [[nested [[baz]]]]"]] ["bar" "test" "baz" "nested [[baz]]"]
  30. [["foo" "#bar, #baz"]] ["bar" "baz"]
  31. [["foo" "[[nested [[page]]]], test"]] ["nested [[page]]" "test"]))
  32. #_(cljs.test/run-tests)