All files / src/controllers/searchResult user.js

100% Statements 14/14
100% Branches 2/2
100% Functions 5/5
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29  1x 1x         18x   18x 18x 37x       9x   8x 2x     12x 6x         1x  
const
  SearchResultBase = require('./base'),
  User = require('../security/user');
 
class UserSearchResult extends SearchResultBase {
 
  constructor (kuzzle, query, options, response) {
    super(kuzzle, query, options, response);
 
    this._searchAction = 'searchUsers';
    this._scrollAction = 'scrollUsers';
    this.hits = this._response.hits.map(hit => new User(this._kuzzle, hit._id, hit._source));
  }
 
  next () {
    return super.next()
      .then(nextSearchResult => {
        if (! nextSearchResult) {
          return null;
        }
 
        nextSearchResult.hits = nextSearchResult._response.hits.map(hit => new User(nextSearchResult._kuzzle, hit._id, hit._source));
        return nextSearchResult;
      });
  }
}
 
module.exports = UserSearchResult;