27 lines
1013 B
Elixir
27 lines
1013 B
Elixir
defmodule FeedParser.Parser.JSONFeedTest do
|
|
use ExUnit.Case
|
|
alias FeedParser.Parser.JSONFeed
|
|
doctest JSONFeed
|
|
|
|
test "matches json feed" do
|
|
data = File.read!("test/fixtures/jsonfeed/feed.json")
|
|
assert {true, _} = JSONFeed.accepts(data, "application/json")
|
|
end
|
|
|
|
test "parses json feed" do
|
|
data = File.read!("test/fixtures/jsonfeed/feed.json")
|
|
{true, parsed_data} = JSONFeed.accepts(data, "application/json")
|
|
assert {:ok, %FeedParser.Feed{} = feed} = JSONFeed.parse_feed(parsed_data)
|
|
assert feed.title == "My Example Feed"
|
|
assert feed.site_url == "https://example.org/"
|
|
assert feed.last_updated == nil
|
|
assert [%FeedParser.Item{} = item2, %FeedParser.Item{} = item1] = feed.items
|
|
assert item2.guid == "2"
|
|
assert item2.content == "This is a second item."
|
|
assert item2.url == "https://example.org/second-item"
|
|
assert item1.guid == "1"
|
|
assert item1.content == "<p>Hello, world!</p>"
|
|
assert item1.url == "https://example.org/initial-post"
|
|
end
|
|
end
|