feed_parser/test/parser/rssinjson_test.exs

24 lines
938 B
Elixir

defmodule FeedParser.Parser.RSSInJSONTest do
use ExUnit.Case
alias FeedParser.Parser.RSSInJSON
doctest RSSInJSON
test "matches rss-in-json feed" do
data = File.read!("test/fixtures/rssinjson/feed.json")
assert {true, _} = RSSInJSON.accepts(data, "application/json")
end
test "parses rss-in-json feed" do
data = File.read!("test/fixtures/rssinjson/feed.json")
{true, parsed_data} = RSSInJSON.accepts(data, "application/json")
assert {:ok, %FeedParser.Feed{} = feed} = RSSInJSON.parse_feed(parsed_data)
assert feed.title == "Scripting News"
assert feed.site_url == "http://scripting.com/"
assert feed.last_updated == ~U[2019-08-31 22:49:49Z]
assert [%FeedParser.Item{} = item] = feed.items
assert item.url == "http://scripting.com/2019/08/31.html#a151142"
assert item.guid == "http://scripting.com/2019/08/31.html#a151142"
assert item.date == ~U[2019-08-31 15:11:42Z]
end
end