'use strict';

var _chai;

function _load_chai() {
  return _chai = require('chai');
}

var _queryBuilder;

function _load_queryBuilder() {
  return _queryBuilder = _interopRequireDefault(require('../../src/search/query-builder'));
}

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

describe('query-builder', function () {
  describe('buildQuery', function () {
    var queryToObject = function queryToObject(query) {
      return query.reduce(function (acc, val) {
        return Object.assign(acc, val.AND);
      }, {});
    };

    it('should produce a clause for the name field as is', function () {
      var query = queryToObject((0, (_queryBuilder || _load_queryBuilder()).default)('is-string'));
      (0, (_chai || _load_chai()).expect)(query.name).to.eql(['is-string']);
    });
    it('should produce a clause for the name field tokenized', function () {
      var query = queryToObject((0, (_queryBuilder || _load_queryBuilder()).default)('is-string'));
      (0, (_chai || _load_chai()).expect)(query.tokenizedName).to.eql(['is', 'string']);
    });
    it('should produce clauses for the stem version of the search query', function () {
      var query = queryToObject((0, (_queryBuilder || _load_queryBuilder()).default)('casting int'));
      (0, (_chai || _load_chai()).expect)(query.stemmedName).to.eql(['cast', 'int']);
      (0, (_chai || _load_chai()).expect)(query.stemmedMinDescription).to.eql(['cast', 'int']);
    });
  });
});