-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
Hello!
I want to test a blog that paginates posts, showing 5 per page. I'd like to get the post list, and check that I can find the post title of the first 10 posts, something like this:
test "Blog post pagination", %{conn: conn} do
get(conn, "/blog")
|> assert_response(status, 200, path: "/blog", html: "Listing recent posts")
|> assert_response(html: "Post title 1")
|> assert_response(html: "Post title 2")
|> assert_response(html: "Post title 3")
|> assert_response(html: "Post title 4")
|> assert_response(html: "Post title 5")
endInstead of this, it would be great if we could pass a list of strings to :html, so we could do this:
test "Blog post pagination", %{conn: conn, posts: posts} do
get(conn, "/blog")
|> assert_response(status, 200, path: "/blog", html: "Listing recent posts")
|> assert_response(html: Enum.map(posts, & &1.title))
endOr this, check for different strings explicitly:
test "Pricing plans", %{conn: conn} do
get(conn, "/pricing")
|> assert_response(status, 200,
path: "/pricing",
html: [
"Pricing",
"Starter plan",
"Pro plan",
"Enterprise plan"
]
)
endSame for refute_response.
What do you think?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels