stemmer_test.js 705 B

1234567891011121314151617181920212223242526
  1. suite('lunr.stemmer', function () {
  2. test('reduces words to their stem', function (done) {
  3. withFixture('stemming_vocab.json', function (err, fixture) {
  4. if (err != null) {
  5. throw err
  6. }
  7. var testData = JSON.parse(fixture)
  8. Object.keys(testData).forEach(function (word) {
  9. var expected = testData[word],
  10. token = new lunr.Token(word),
  11. result = lunr.stemmer(token).toString()
  12. assert.equal(expected, result)
  13. })
  14. done()
  15. })
  16. })
  17. test('is a registered pipeline function', function () {
  18. assert.equal('stemmer', lunr.stemmer.label)
  19. assert.equal(lunr.stemmer, lunr.Pipeline.registeredFunctions['stemmer'])
  20. })
  21. })