Update to allow search book by an empty bid.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
5c31715211
commit
3bc4616c5d
@ -0,0 +1,45 @@
|
||||
defmodule DecentralisedBookIndexWeb.Live.BookLive.IndexTest do
|
||||
use DecentralisedBookIndexWeb.LiveCase, async: true
|
||||
|
||||
describe "Search by bid" do
|
||||
setup do
|
||||
%{
|
||||
modes: [
|
||||
"isbn",
|
||||
"isbn13",
|
||||
"asin"
|
||||
],
|
||||
books:
|
||||
for _ <- 1..5 do
|
||||
generate(book())
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
test "can search by an empty bid", %{conn: conn, modes: modes} do
|
||||
for mode <- modes do
|
||||
{:ok, _view, html} =
|
||||
conn
|
||||
|> live("/books?search_mode=#{mode}")
|
||||
|
||||
assert html =~ "Listing Books"
|
||||
assert html =~ "No Books"
|
||||
end
|
||||
end
|
||||
|
||||
test "can search by a bid", %{conn: conn, modes: modes, books: books} do
|
||||
[book | others] = books
|
||||
|
||||
for %{type: type, bid: bid} <- book.bids do
|
||||
{:ok, view, html} =
|
||||
conn
|
||||
|> live("/books?query=#{bid}&search_mode=#{type}")
|
||||
|
||||
html = render(view)
|
||||
|
||||
assert html =~ book.title
|
||||
refute html =~ "No Books"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in new issue