Turns a name into the URL of its page
All 24 scenarios hold
A page needs two names: the title a reader sees, and the file name the URL ends in. Both come from the test that produced the page. A class or method that carries a @DisplayName supplies its own title, and the rules below are what happens when it does not.
A name that keeps a letter through the ASCII fold slugs exactly as it always has. A name that does not — one written in a script the fold has no answer for — keeps its own characters instead of collapsing to an unusable empty filename, and a name with no letters or digits anywhere falls back to a stable hash so that two of them still get two filenames.
Words are separated before the fold runs. A name that holds a space or an underscore is separated there and is not also split at its capitals.
| Scenario | Name | URL? |
|---|---|---|
| CamelCase | LeapYearRules | leap-year-rules |
| An acronym beside a word | parseHTMLDocument | parse-html-document |
| A digit before a word | test123Method | test123-method |
| A single letter | A | a |
| Snake case | leap_year_rules | leap-year-rules |
| Snake case with capitals | TestClass_MethodName | testclass-methodname |
| Spaces | Leap Year Rules | leap-year-rules |
| Spaces and underscores | test_method with spaces | test-method-with-spaces |
| Punctuation inside the name | test@example.com | test-example-com |
| Punctuation ending the name | A Custom Test Title! | a-custom-test-title |
| Accented letters | naïve façade | naive-facade |
| Ligature letters | Grüße aus München | grusse-aus-munchen |
| Nordic letters | ÆØÅ | aeoa |
| Thorn without Latin base | Þingvellir | thingvellir |
| Compatibility ligature | file flow | file-flow |
| Greek script | Ελληνικά | ελληνικά |
| Cyrillic script | Москва | москва |
| CJK script | 日本語のテスト | 日本語のテスト |
| Cyrillic camelCase | проверкаИмени | проверка-имени |
| Digits and no letters | 123 | 123 |
| No letters or digits | !!! | unnamed-00008001 |
| Another with neither | ??? | unnamed-0000f45f |
| An empty name | “” | “” |
| No name at all |