mldoc-test.cljs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. (ns frontend.format.mldoc-test
  2. (:require [frontend.format.mldoc :as mldoc]
  3. [cljs.test :refer [testing deftest are]]))
  4. (deftest test-link
  5. (testing "non-link"
  6. (are [x y] (= (mldoc/link? :markdown x) y)
  7. "google.com" false))
  8. (testing "plain links"
  9. (are [x y] (= (mldoc/link? :markdown x) y)
  10. "http://www.google.com" true
  11. "http://google.com" true))
  12. (testing "org links with labels"
  13. (are [x y] (= (mldoc/link? :org x) y)
  14. "[[http://www.google.com][google]]" true
  15. "[[http://google.com][google]]" true
  16. "[[https://www.google.com][google]]" true
  17. "[[https://google.com][google]]" true))
  18. (testing "org links without labels"
  19. (are [x y] (= (mldoc/link? :org x) y)
  20. "[[http://www.google.com]]" true
  21. "[[https://www.google.com]]" true))
  22. (testing "markdown links"
  23. (are [x y] (= (mldoc/link? :markdown x) y)
  24. "[google](http://www.google.com)" true
  25. "[google](https://www.google.com)" true))
  26. ;; https://github.com/logseq/logseq/issues/4308
  27. (testing "parsing links should be finished"
  28. (are [x y] (= (mldoc/link? :markdown x) y)
  29. "[YouTube](https://www.youtube.com/watch?v=-8ym7pyUs9gL) - [Vimeo](https://vimeo.com/677920303) {{youtube https://www.youtube.com/watch?v=-8ym7pyUs9g}}" true)))