feed_parser/test/parser/atom_test.exs

26 lines
979 B
Elixir

defmodule FeedParser.Parser.AtomTest do
use ExUnit.Case
alias FeedParser.Parser.Atom
doctest Atom
test "matches atom feed" do
data = File.read!("test/fixtures/atom/feed.xml")
assert {true, _} = Atom.accepts(data, "application/atom+xml")
assert {true, _} = Atom.accepts(data, "application/xml")
end
test "parses atom feed" do
data = File.read!("test/fixtures/atom/feed.xml")
{true, parsed_data} = Atom.accepts(data, "application/atom+xml")
assert {:ok, %FeedParser.Feed{} = feed} = Atom.parse_feed(parsed_data)
assert feed.site_url == "http://example.org/"
assert feed.title == "Example Feed"
assert [%FeedParser.Item{} = item] = feed.items
assert item.guid == "urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a"
assert item.title == "Atom-Powered Robots Run Amok"
assert item.url == "http://example.org/2003/12/13/atom03"
assert item.date == ~U[2003-12-13 18:30:02Z]
assert item.content == "Some text."
end
end