版博士V2.0程序
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

73 lignes
3.1 KiB

  1. import { inspect } from "util";
  2. import { titleCase } from ".";
  3. /**
  4. * Based on https://github.com/gouch/to-title-case/blob/master/test/tests.json.
  5. */
  6. var TEST_CASES = [
  7. ["", ""],
  8. ["2019", "2019"],
  9. ["test", "Test"],
  10. ["two words", "Two Words"],
  11. ["one. two.", "One. Two."],
  12. ["a small word starts", "A Small Word Starts"],
  13. ["small word ends on", "Small Word Ends On"],
  14. ["we keep NASA capitalized", "We Keep NASA Capitalized"],
  15. ["pass camelCase through", "Pass camelCase Through"],
  16. ["follow step-by-step instructions", "Follow Step-by-Step Instructions"],
  17. ["your hair[cut] looks (nice)", "Your Hair[cut] Looks (Nice)"],
  18. ["leave Q&A unscathed", "Leave Q&A Unscathed"],
  19. [
  20. "piña colada while you listen to ænima",
  21. "Piña Colada While You Listen to Ænima",
  22. ],
  23. ["start title – end title", "Start Title – End Title"],
  24. ["start title–end title", "Start Title–End Title"],
  25. ["start title — end title", "Start Title — End Title"],
  26. ["start title—end title", "Start Title—End Title"],
  27. ["start title - end title", "Start Title - End Title"],
  28. ["don't break", "Don't Break"],
  29. ['"double quotes"', '"Double Quotes"'],
  30. ['double quotes "inner" word', 'Double Quotes "Inner" Word'],
  31. ["fancy double quotes “inner” word", "Fancy Double Quotes “Inner” Word"],
  32. ["have you read “The Lottery”?", "Have You Read “The Lottery”?"],
  33. ["one: two", "One: Two"],
  34. ["one two: three four", "One Two: Three Four"],
  35. ['one two: "Three Four"', 'One Two: "Three Four"'],
  36. ["email email@example.com address", "Email email@example.com Address"],
  37. [
  38. "you have an https://example.com/ title",
  39. "You Have an https://example.com/ Title",
  40. ],
  41. ["_underscores around words_", "_Underscores Around Words_"],
  42. ["*asterisks around words*", "*Asterisks Around Words*"],
  43. ["this vs. that", "This vs. That"],
  44. ["this vs that", "This vs That"],
  45. ["this v. that", "This v. That"],
  46. ["this v that", "This v That"],
  47. [
  48. "Scott Moritz and TheStreet.com’s million iPhone la-la land",
  49. "Scott Moritz and TheStreet.com’s Million iPhone La-La Land",
  50. ],
  51. [
  52. "Notes and observations regarding Apple’s announcements from ‘The Beat Goes On’ special event",
  53. "Notes and Observations Regarding Apple’s Announcements From ‘The Beat Goes On’ Special Event",
  54. ],
  55. [
  56. "the quick brown fox jumps over the lazy dog",
  57. "The Quick Brown Fox Jumps over the Lazy Dog",
  58. ],
  59. ["newcastle upon tyne", "Newcastle upon Tyne"],
  60. ["newcastle *upon* tyne", "Newcastle *upon* Tyne"],
  61. ];
  62. describe("swap case", function () {
  63. var _loop_1 = function (input, result) {
  64. it(inspect(input) + " -> " + inspect(result), function () {
  65. expect(titleCase(input)).toEqual(result);
  66. });
  67. };
  68. for (var _i = 0, TEST_CASES_1 = TEST_CASES; _i < TEST_CASES_1.length; _i++) {
  69. var _a = TEST_CASES_1[_i], input = _a[0], result = _a[1];
  70. _loop_1(input, result);
  71. }
  72. });
  73. //# sourceMappingURL=index.spec.js.map