Skip to content

Commit

Permalink
default_sort_order indication test
Browse files Browse the repository at this point in the history
  • Loading branch information
berycz authored and boxed committed Mar 11, 2024
1 parent c1db0f9 commit da8badf
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions iommi/table__tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4288,3 +4288,41 @@ class Meta:
actual_html=new_html,
expected_html=expected_container_content,
)


@pytest.mark.django_db
def test_default_sort_order_django_table_from_model():
foos = [
TFoo.objects.create(a=4711, b="c"),
TFoo.objects.create(a=17, b="a"),
TFoo.objects.create(a=42, b="b"),
]

verify_table_html(
table=Table(auto__rows=TFoo.objects.all(), default_sort_order="-a"),
# language=html
expected_html=f"""
<table class="table" >
<thead>
<tr>
<th class="descending first_column iommi_sort_header sorted subheader"> <a href="?order=a"> A </a> </th>
<th class="first_column iommi_sort_header subheader"> <a href="?order=b"> B </a> </th>
</tr>
</thead>
<tbody>
<tr data-pk="{foos[0].pk}">
<td class="rj"> 4711 </td>
<td> c </td>
</tr>
<tr data-pk="{foos[2].pk}">
<td class="rj"> 42 </td>
<td> b </td>
</tr>
<tr data-pk="{foos[1].pk}">
<td class="rj"> 17 </td>
<td> a </td>
</tr>
</tbody>
</table>
""",
)

0 comments on commit da8badf

Please sign in to comment.