All files / src/controllers/searchResult profile.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
  Profile = require('../security/profile'),
  SearchResultBase = require('./base');
 
class ProfileSearchResult extends SearchResultBase {
 
  constructor (kuzzle, request, options, response) {
    super(kuzzle, request, options, response);
 
    this._searchAction = 'searchProfiles';
    this._scrollAction = 'scrollProfiles';
    this.hits = response.hits.map(hit => new Profile(this._kuzzle, hit._id, hit._source.policies));
  }
 
  next () {
    return super.next()
      .then(nextSearchResult => {
        if (! nextSearchResult) {
          return null;
        }
 
        nextSearchResult.hits = nextSearchResult._response.hits.map(hit => new Profile(nextSearchResult._kuzzle, hit._id, hit._source.policies));
        return nextSearchResult;
      });
  }
}
 
module.exports = ProfileSearchResult;