trimmer_test.js 835 B

123456789101112131415161718192021222324252627
  1. module('lunr.trimmer')
  2. test('latin characters', function () {
  3. var token = 'hello'
  4. equal(lunr.trimmer(token), token)
  5. })
  6. test('removing leading and trailing punctuation', function () {
  7. var fullStop = 'hello.',
  8. innerApostrophe = "it's",
  9. trailingApostrophe = "james'",
  10. exclamationMark = 'stop!',
  11. comma = 'first,',
  12. brackets = '[tag]'
  13. deepEqual(lunr.trimmer(fullStop), 'hello')
  14. deepEqual(lunr.trimmer(innerApostrophe), "it's")
  15. deepEqual(lunr.trimmer(trailingApostrophe), "james")
  16. deepEqual(lunr.trimmer(exclamationMark), 'stop')
  17. deepEqual(lunr.trimmer(comma), 'first')
  18. deepEqual(lunr.trimmer(brackets), 'tag')
  19. })
  20. test('should be registered with lunr.Pipeline', function () {
  21. equal(lunr.trimmer.label, 'trimmer')
  22. deepEqual(lunr.Pipeline.registeredFunctions['trimmer'], lunr.trimmer)
  23. })