test-titlecase.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* global describe,it */
  2. var getSlug = require('../lib/speakingurl');
  3. describe('getSlug titleCase', function () {
  4. 'use strict';
  5. it('should title-case the characters', function (done) {
  6. getSlug('This is big foo', {
  7. titleCase: true
  8. })
  9. .should.eql('This-Is-Big-Foo');
  10. getSlug('This is Big foo', {
  11. titleCase: true
  12. })
  13. .should.eql('This-Is-Big-Foo');
  14. getSlug('Don\'t drink and drive', {
  15. titleCase: true
  16. })
  17. .should.eql('Don-t-Drink-And-Drive');
  18. done();
  19. });
  20. it('should title-case the characters with custom array', function (done) {
  21. getSlug('This is yet foo and bar', {
  22. titleCase: ['and', 'yet']
  23. })
  24. .should.eql('This-Is-yet-Foo-and-Bar');
  25. getSlug('This is a foo and an angry bird', {
  26. titleCase: ['a', 'an', 'and']
  27. })
  28. .should.eql('This-Is-a-Foo-and-an-Angry-Bird');
  29. getSlug('This is a foo and an angry bird show', {
  30. titleCase: ['a']
  31. })
  32. .should.eql('This-Is-a-Foo-And-An-Angry-Bird-Show');
  33. getSlug('Don\'t drink and drive', {
  34. titleCase: ['and']
  35. })
  36. .should.eql('Don-t-Drink-and-Drive');
  37. getSlug('Don\'t drink and drive', {
  38. titleCase: {}
  39. })
  40. .should.eql('Don-t-Drink-And-Drive');
  41. getSlug('Don\'t drink and drive', {
  42. titleCase: {
  43. 'drink': 'drive'
  44. }
  45. })
  46. .should.eql('Don-t-Drink-And-Drive');
  47. getSlug('Don\'t drink and drive', {
  48. titleCase: 42
  49. })
  50. .should.eql('Don-t-Drink-And-Drive');
  51. done();
  52. });
  53. });