-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Add reading_time component (#388)
- Loading branch information
Showing
5 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
defmodule BeaconWeb.ComponentsTest do | ||
use BeaconWeb.ConnCase, async: false | ||
|
||
import Phoenix.LiveViewTest | ||
import Phoenix.ConnTest | ||
import Beacon.Fixtures | ||
|
||
setup_all do | ||
start_supervised!({Beacon.Loader, Beacon.Config.fetch!(:my_site)}) | ||
:ok | ||
end | ||
|
||
describe "image" do | ||
setup context do | ||
create_page_with_component(""" | ||
<main> | ||
<p> | ||
#{Faker.Lorem.words(901) |> Enum.join(" ")} | ||
</p> | ||
<BeaconWeb.Components.reading_time /> min to read | ||
</main> | ||
""") | ||
|
||
context | ||
end | ||
|
||
test "SUCCESS: reading_time should show 1 min to read the page", %{conn: conn} do | ||
{:ok, view, _html} = live(conn, "/home") | ||
|
||
assert render(view) =~ "3 min to read" | ||
end | ||
end | ||
|
||
defp create_page_with_component(template) do | ||
layout = published_layout_fixture() | ||
|
||
published_page_fixture( | ||
layout_id: layout.id, | ||
path: "home", | ||
template: template | ||
) | ||
|
||
Beacon.Loader.load_components(:my_site) | ||
Beacon.Loader.load_pages(:my_site) | ||
end | ||
end |