@@ -59,6 +59,30 @@ def test_pretty_names_from_filename(self):
5959 self .assertEqual (display_link .text .strip (), "test_molecule_no_context.html" )
6060 self .assertEqual (render_link .text .strip (), pattern_path )
6161
62+ def test_pretty_names_from_filename_containing_dashes (self ):
63+ pattern_path = "patterns/molecules/test-molecule/test-molecule.html"
64+ test_molecule_display_url = reverse (
65+ "pattern_library:display_pattern" ,
66+ kwargs = {"pattern_template_name" : pattern_path },
67+ )
68+ test_molecule_render_url = reverse (
69+ "pattern_library:render_pattern" ,
70+ kwargs = {"pattern_template_name" : pattern_path },
71+ )
72+
73+ response = self .client .get (test_molecule_display_url )
74+ self .assertEqual (response .status_code , 200 )
75+
76+ soup = BeautifulSoup (response .content , features = "html.parser" )
77+
78+ display_link = soup .select_one (
79+ f'.list__item>a[href="{ test_molecule_display_url } "]'
80+ )
81+ render_link = soup .select_one (f'a[href="{ test_molecule_render_url } "]' )
82+
83+ self .assertEqual (display_link .text .strip (), "test-molecule.html" )
84+ self .assertEqual (render_link .text .strip (), pattern_path )
85+
6286 def test_includes (self ):
6387 pattern_path = "patterns/atoms/test_includes/test_includes.html"
6488 display_url = reverse (
@@ -92,6 +116,7 @@ def test_fragments(self):
92116 for template_name in [
93117 "patterns/atoms/test_atom/test_atom.html" ,
94118 "patterns/molecules/test_molecule/test_molecule.html" ,
119+ "patterns/molecules/test-molecule/test-molecule.html" ,
95120 ]:
96121 with self .subTest (template_name = template_name ):
97122 self .assertContains (
0 commit comments