You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

49 lines
1.3 KiB

  1. defmodule Microformats2Test do
  2. use ExUnit.Case
  3. doctest Microformats2
  4. test "parse successfully parses rels" do
  5. assert(Microformats2.parse("<a rel=\"me\" href=\"http://blub\">blub</a>") ==
  6. %{items: [],
  7. rel_urls: %{"http://blub" => ["me"]},
  8. rels: %{"me" => ["http://blub"]}})
  9. end
  10. test "parse successfully parses multiple rels" do
  11. assert(Microformats2.parse("""
  12. <a rel=\"me\" href=\"http://blub\">blub</a>
  13. <a rel=\"me\" href=\"http://blah\">blub</a>
  14. """) ==
  15. %{items: [],
  16. rel_urls: %{"http://blub" => ["me"],
  17. "http://blah" => ["me"]},
  18. rels: %{"me" => ["http://blub", "http://blah"]}})
  19. end
  20. test "parse only saves one URL" do
  21. assert(Microformats2.parse("""
  22. <a rel=\"me\" href=\"http://blub\">blub</a>
  23. <a rel=\"me\" href=\"http://blub\">blub</a>
  24. """) ==
  25. %{items: [],
  26. rel_urls: %{"http://blub" => ["me"]},
  27. rels: %{"me" => ["http://blub"]}})
  28. end
  29. test "parse saves all rels" do
  30. assert(Microformats2.parse("""
  31. <a rel=\"me\" href=\"http://blub\">blub</a>
  32. <a rel=\"moo\" href=\"http://blub\">blub</a>
  33. """) ==
  34. %{items: [],
  35. rel_urls: %{"http://blub" => ["me", "moo"]},
  36. rels: %{"me" => ["http://blub"],
  37. "moo" => ["http://blub"]}})
  38. end
  39. test "parse generates an absolute URL" do
  40. assert false, "TODO"
  41. end
  42. end