Skip to content

Commit

Permalink
Add tests for the attribute fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkrzyskow committed Mar 16, 2023
1 parent 307002d commit 4cbae0d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mkdocs_awesome_pages_plugin/tests/e2e/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ def createConfig(
collapse_single_pages: Optional[bool] = None,
mkdocs_nav: Optional[List[Union[str, Dict[str, Union[str, list]]]]] = None,
strict: Optional[bool] = None,
order: Optional[str] = None,
sort_type: Optional[str] = None,
) -> dict:
plugin_options = self._removeDictNoneValues(
{
"filename": filename,
"collapse_single_pages": collapse_single_pages,
"strict": strict,
"order": order,
"sort_type": sort_type,
}
)
plugins_entry = "awesome-pages"
Expand Down
46 changes: 46 additions & 0 deletions mkdocs_awesome_pages_plugin/tests/e2e/test_order_and_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,49 @@ def test_nav_rest_desc_natural(self):
("20", [("3", "/20/3"), ("100", "/20/100"), ("20", "/20/20")]),
],
)

def test_global_asc_without_local(self):
navigation = self.mkdocs(
self.createConfig(order="asc"),
[
"1.md",
"3.md",
("2", ["1.md", "2.md"]),
],
)

self.assertEqual(
navigation,
[("1", "/1"), ("2", [("1", "/2/1"), ("2", "/2/2")]), ("3", "/3")],
)

def test_global_asc_local_desc(self):
navigation = self.mkdocs(
self.createConfig(order="asc"),
[
"1.md",
"3.md",
("2", ["1.md", "2.md", self.pagesFile(order="desc")]),
self.pagesFile(order="desc"),
],
)

self.assertEqual(
navigation,
[("3", "/3"), ("2", [("2", "/2/2"), ("1", "/2/1")]), ("1", "/1")],
)

def test_global_asc_natural_without_local(self):
navigation = self.mkdocs(
self.createConfig(order="asc", sort_type="natural"),
[
"100.md",
"3.md",
("20", ["100.md", "20.md"]),
],
)

self.assertEqual(
navigation,
[("3", "/3"), ("20", [("20", "/20/20"), ("100", "/20/100")]), ("100", "/100")],
)

0 comments on commit 4cbae0d

Please sign in to comment.