testing_library_dom/queries/
placeholder_text.rs1use web_sys::HtmlElement;
2
3use crate::{
4 build_queries,
5 error::QueryError,
6 query_helpers::query_all_by_attribute,
7 types::{Matcher, MatcherOptions},
8};
9
10pub fn _query_all_by_placeholder_text<M: Into<Matcher>>(
11 container: &HtmlElement,
12 text: M,
13 options: MatcherOptions,
14) -> Result<Vec<HtmlElement>, QueryError> {
15 query_all_by_attribute("placeholder".to_string(), container, text, options)
16}
17
18fn get_multiple_error(
19 _container: &HtmlElement,
20 text: Matcher,
21 _options: MatcherOptions,
22) -> Result<String, QueryError> {
23 Ok(format!(
24 "Found multiple elements with the placeholder text: {text}"
25 ))
26}
27
28fn get_missing_error(
29 _container: &HtmlElement,
30 text: Matcher,
31 _options: MatcherOptions,
32) -> Result<String, QueryError> {
33 Ok(format!(
34 "Unable to find an element with the placeholder text: {text}"
35 ))
36}
37
38build_queries!(
39 _query_all_by_placeholder_text,
40 get_multiple_error,
41 get_missing_error,
42 placeholder_text,
43 crate::types::Matcher,
44 crate::types::MatcherOptions
45);
46
47pub use internal::{
48 find_all_by_placeholder_text, find_by_placeholder_text, get_all_by_placeholder_text,
49 get_by_placeholder_text, query_all_by_placeholder_text, query_by_placeholder_text,
50};