# Path: test/common_test_util.py
# def expected_result(contents):
#     return dedent(contents.lstrip('\n'))
# 
# Path: test/hquery/hquery_test_util.py
# def query_html_doc(html_body, hquery, preserve_space=False, wrap_body=True):
#     soup = soup_with_body(html_body) if wrap_body else make_soup(html_body)
#     raw_result = HqueryProcessor(hquery, preserve_space=preserve_space).query(soup)
#     return eliminate_blank_lines(convert_results_to_output_text(raw_result, preserve_space=preserve_space).strip())


from test.common_test_util import expected_result
from test.hquery.hquery_test_util import query_html_doc


def test_if_then_else_works_with_literal_conditions():
    assert query_html_doc('', 'if (true()) then "foo" else "bar"') == 'foo'
    assert query_html_doc('', 'if ("") then "foo" else "bar"') == 'bar'
    assert query_html_doc('', 'if (0.001) then "foo" else "bar"') == 'foo'


def test_if_then_else_works_with_node_sets():
    html_body = """
    <p>eekaboo</p>"""

# Path: test/common_test_util.py
# def expected_result(contents):
#     return dedent(contents.lstrip('\n'))
# 
# Path: test/hquery/hquery_test_util.py
# def query_html_doc(html_body, hquery, preserve_space=False, wrap_body=True):
#     soup = soup_with_body(html_body) if wrap_body else make_soup(html_body)
#     raw_result = HqueryProcessor(hquery, preserve_space=preserve_space).query(soup)
#     return eliminate_blank_lines(convert_results_to_output_text(raw_result, preserve_space=preserve_space).strip())


# Path: test/hquery/test_if_then_else.py
from test.common_test_util import expected_result
from test.hquery.hquery_test_util import query_html_doc



def test_if_then_else_works_with_literal_conditions():
    assert query_html_doc('', 'if (true()) then "foo" else "bar"') == 'foo'
    assert query_html_doc('', 'if ("") then "foo" else "bar"') == 'bar'
    assert query_html_doc('', 'if (0.001) then "foo" else "bar"') == 'foo'


def test_if_then_else_works_with_node_sets():
    html_body = """
    <p>eekaboo</p>"""

    assert query_html_doc(html_body, 'if (//p) then //p else 1 to 3') == expected_result("""