add tests
This commit is contained in:
1 parent
94a51e0322
commit
7d0c5d9ae7
2 files changed
+69
No files matched your search
@@ -0,0 +1,30 @@
|
|||||||
|
defmodule FeedReader.FeedTest do
|
||||||
|
use ExUnit.Case, async: true
|
||||||
|
|
||||||
|
alias FeedReader.Feed
|
||||||
|
|
||||||
|
test "uses empty normalized metadata defaults" do
|
||||||
|
assert %Feed{
|
||||||
|
title: nil,
|
||||||
|
description: nil,
|
||||||
|
feed_url: nil,
|
||||||
|
html_url: nil,
|
||||||
|
type: nil,
|
||||||
|
categories: [],
|
||||||
|
extensions: %{}
|
||||||
|
} = %Feed{}
|
||||||
|
end
|
||||||
|
|
||||||
|
test "stores feed metadata and namespace extensions" do
|
||||||
|
feed = %Feed{
|
||||||
|
title: "Example",
|
||||||
|
type: :rss,
|
||||||
|
categories: ["news"],
|
||||||
|
extensions: %{"urn:example" => %{"priority" => 1}}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert feed.title == "Example"
|
||||||
|
assert feed.type == :rss
|
||||||
|
assert feed.extensions["urn:example"]["priority"] == 1
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
defmodule FeedReader.ItemTest do
|
||||||
|
use ExUnit.Case, async: true
|
||||||
|
|
||||||
|
alias FeedReader.Item
|
||||||
|
|
||||||
|
test "uses empty normalized item defaults" do
|
||||||
|
assert %Item{
|
||||||
|
uuid: nil,
|
||||||
|
title: nil,
|
||||||
|
content_full: nil,
|
||||||
|
content_summary: nil,
|
||||||
|
language: nil,
|
||||||
|
published_at: nil,
|
||||||
|
canonical_url: nil,
|
||||||
|
alternate: %{},
|
||||||
|
author: nil,
|
||||||
|
extensions: %{}
|
||||||
|
} = %Item{}
|
||||||
|
end
|
||||||
|
|
||||||
|
test "stores normalized content and extension metadata" do
|
||||||
|
published_at = ~U[2026-01-01 12:00:00Z]
|
||||||
|
|
||||||
|
item = %Item{
|
||||||
|
uuid: "item-1",
|
||||||
|
title: "Example item",
|
||||||
|
content_summary: "Summary",
|
||||||
|
language: :en,
|
||||||
|
published_at: published_at,
|
||||||
|
canonical_url: "https://example.com/item-1",
|
||||||
|
author: "Author",
|
||||||
|
extensions: %{"urn:example" => %{"rating" => "safe"}}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert item.uuid == "item-1"
|
||||||
|
assert item.published_at == published_at
|
||||||
|
assert item.extensions["urn:example"]["rating"] == "safe"
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in new issue
Block a user