test-accent.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* global describe,it, before */
  2. describe('getSlug translate sentence with accent words', function () {
  3. 'use strict';
  4. describe('default options', function () {
  5. var getSlug = require('../lib/speakingurl').createSlug({
  6. });
  7. it('single word', function (done) {
  8. getSlug('Ánhanguera')
  9. .should.eql('anhanguera');
  10. done();
  11. });
  12. it('middle of sentence', function (done) {
  13. getSlug('foo Ánhanguera bar')
  14. .should.eql('foo-anhanguera-bar');
  15. done();
  16. });
  17. it('beginning of sentence', function (done) {
  18. getSlug('Ánhanguera foo bar')
  19. .should.eql('anhanguera-foo-bar');
  20. done();
  21. });
  22. it('end of sentence', function (done) {
  23. getSlug('Ánhanguera fooá')
  24. .should.eql('anhanguera-fooa');
  25. done();
  26. });
  27. });
  28. describe('titlecase options', function () {
  29. var getSlug = require('../lib/speakingurl').createSlug({
  30. titleCase: [
  31. 'a', 'an', 'and', 'as', 'at', 'but',
  32. 'by', 'en', 'for', 'if', 'in', 'nor',
  33. 'of', 'on', 'or', 'per', 'the', 'to', 'vs'
  34. ]
  35. });
  36. it('single word', function (done) {
  37. getSlug('Ánhanguera')
  38. .should.eql('Anhanguera');
  39. done();
  40. });
  41. it('middle of sentence', function (done) {
  42. getSlug('foo Ánhanguera bar')
  43. .should.eql('Foo-Anhanguera-Bar');
  44. done();
  45. });
  46. it('middle of sentence, with exception', function (done) {
  47. getSlug('foo Ánhanguera And bar')
  48. .should.eql('Foo-Anhanguera-and-Bar');
  49. done();
  50. });
  51. it('beginning of sentence', function (done) {
  52. getSlug('Ánhanguera foo Ánhanguera')
  53. .should.eql('Anhanguera-Foo-Anhanguera');
  54. done();
  55. });
  56. it('beginning of sentence, with exception', function (done) {
  57. getSlug('Ánhanguera and Ánhanguera')
  58. .should.eql('Anhanguera-and-Anhanguera');
  59. done();
  60. });
  61. it('end of sentence', function (done) {
  62. getSlug('Ánhanguera foo bará')
  63. .should.eql('Anhanguera-Foo-Bara');
  64. done();
  65. });
  66. it('end of sentence, with exception', function (done) {
  67. getSlug('Ánhanguera foo and bará')
  68. .should.eql('Anhanguera-Foo-and-Bara');
  69. done();
  70. });
  71. });
  72. });