Skip to content

Commit

Permalink
Add the correct error message for text queries
Browse files Browse the repository at this point in the history
  • Loading branch information
keathley committed Jul 20, 2017
1 parent 0b0453e commit 2265e89
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/wallaby/query/error_message.ex
Expand Up @@ -113,6 +113,8 @@ defmodule Wallaby.Query.ErrorMessage do
def method(:file_field, true), do: "file fields"
def method(:file_field, false), do: "file field"

def method(:text, true), do: "elements with the text"
def method(:text, false), do: "element with the text"

def short_method(:css, count) when count > 1, do: "elements"
def short_method(:css, count) when count == 0, do: "elements"
Expand Down
18 changes: 18 additions & 0 deletions test/wallaby/query/error_message_test.exs
Expand Up @@ -91,6 +91,24 @@ defmodule Wallaby.Query.ErrorMessageTest do

assert message =~ ~r/query is invalid/
end

test "with text queries" do
message =
Query.text("test")
|> ErrorMessage.message(:not_found)
|> format
assert message == format """
Expected to find 1, visible element with the text 'test' but 0, visible elements with the text were found.
"""

message =
Query.text("test", count: 2)
|> ErrorMessage.message(:not_found)
|> format
assert message == format """
Expected to find 2, visible elements with the text 'test' but 0, visible elements with the text were found.
"""
end
end

describe "visibility/1" do
Expand Down

0 comments on commit 2265e89

Please sign in to comment.