lunr_test.js 781 B

12345678910111213141516171819202122232425262728293031323334353637
  1. module('lunr')
  2. test('returns a new instance of lunr.Index', function () {
  3. var index = lunr()
  4. equal(index.constructor, lunr.Index)
  5. })
  6. test('should set up the pipeline', function () {
  7. var index = lunr(),
  8. stack = index.pipeline._stack
  9. equal(stack.length, 3)
  10. equal(stack.indexOf(lunr.trimmer), 0)
  11. equal(stack.indexOf(lunr.stopWordFilter), 1)
  12. equal(stack.indexOf(lunr.stemmer), 2)
  13. })
  14. test('passing a config fn which is called with the new index', function () {
  15. var configCtx, configArg
  16. var index = lunr(function (idx) {
  17. configCtx = this
  18. configArg = idx
  19. this.ref('cid')
  20. this.field('title', 10)
  21. this.field('body')
  22. })
  23. equal(configCtx, index)
  24. equal(configArg, index)
  25. equal(index._ref, 'cid')
  26. equal(index._fields.length, 2)
  27. })