@@ -168,13 +168,49 @@ describe('core/render/tpl', () => {
168168
169169describe ( 'core/render/slugify' , ( ) => {
170170 test ( 'slugify()' , ( ) => {
171- const result = slugify (
171+ const htmlStrippedSlug = slugify (
172172 'Bla bla bla <svg aria-label="broken" class="broken" viewPort="0 0 1 1"><circle cx="0.5" cy="0.5"/></svg>' ,
173173 ) ;
174- const result2 = slugify (
174+ expect ( htmlStrippedSlug ) . toBe ( 'bla-bla-bla-' ) ;
175+
176+ const nestedHtmlStrippedSlug = slugify (
175177 'Another <span style="font-size: 1.2em" class="foo bar baz">broken <span class="aaa">example</span></span>' ,
176178 ) ;
177- expect ( result ) . toBe ( 'bla-bla-bla-' ) ;
178- expect ( result2 ) . toBe ( 'another-broken-example' ) ;
179+ expect ( nestedHtmlStrippedSlug ) . toBe ( 'another-broken-example' ) ;
180+
181+ const emojiRemovedSlug = slugify ( 'emoji test ⚠️🔥✅' ) ;
182+ expect ( emojiRemovedSlug ) . toBe ( 'emoji-test-️' ) ;
183+
184+ const multiSpaceSlug = slugify ( 'Title with multiple spaces' ) ;
185+ expect ( multiSpaceSlug ) . toBe ( 'title----with---multiple-spaces' ) ;
186+
187+ const numberLeadingSlug = slugify ( '123abc' ) ;
188+ expect ( numberLeadingSlug ) . toBe ( '_123abc' ) ;
189+
190+ const firstDuplicate = slugify ( 'duplicate' ) ;
191+ expect ( firstDuplicate ) . toBe ( 'duplicate' ) ;
192+
193+ const secondDuplicate = slugify ( 'duplicate' ) ;
194+ expect ( secondDuplicate ) . toBe ( 'duplicate-1' ) ;
195+
196+ const thirdDuplicate = slugify ( 'duplicate' ) ;
197+ expect ( thirdDuplicate ) . toBe ( 'duplicate-2' ) ;
198+
199+ const mixedCaseSlug = slugify ( 'This Is Mixed CASE' ) ;
200+ expect ( mixedCaseSlug ) . toBe ( 'this-is-mixed-case' ) ;
201+
202+ const chinesePreservedSlug = slugify ( '你好 world' ) ;
203+ expect ( chinesePreservedSlug ) . toBe ( '你好-world' ) ;
204+
205+ const specialCharSlug = slugify ( 'C++ vs. Java & Python!' ) ;
206+ expect ( specialCharSlug ) . toBe ( 'c-vs-java--python' ) ;
207+
208+ const docsifyIgnoreSlug = slugify (
209+ 'Ignore Heading <!-- {docsify-ignore} -->' ,
210+ ) ;
211+ expect ( docsifyIgnoreSlug ) . toBe ( 'ignore-heading-' ) ;
212+
213+ const quoteCleanedSlug = slugify ( '"The content"' ) ;
214+ expect ( quoteCleanedSlug ) . toBe ( 'the-content' ) ;
179215 } ) ;
180216} ) ;
0 commit comments