<commit_before>'use strict';

/**
 * @file
 * Testing the AutoComplete.store
 */
import {assert, expect} from 'chai';
import AutoCompleteStore from '../AutoComplete.store';

describe('Testing the AutoComplete Store', () => {

  it('AutoCompleteStore.addLinks should return array containing an object with an key named imageComp', () => {
    const data = [{
      pid: null
    }];
    const result = AutoCompleteStore.addLinks(data, 'display.creator');
    assert.isArray(result, 'Got array');
    assert.lengthOf(result, 1, 'Got array of length 1');
    assert.property(result[0], 'imageComp', 'Found key imageComp');
  });

  it('Should return array one containing an object with an key named imageComp', () => {
    const data = [{
      pid: 'hest'
    }];
    const result = AutoCompleteStore.addLinks(data, 'display.creator');
    assert.isArray(result, 'Got array');
    assert.lengthOf(result, 1, 'Got array of length 1');
    assert.property(result[0], 'imageComp', 'Found key imageComp');
  });

  it('AutoComplete.parseResponse should return empty object', () => {
    const response = {
      index: '',
      query: ''
    };

    const result = AutoCompleteStore.parseResponse(response, {});
    assert.isObject(result, 'Got object');
    expect(result).to.be.empty; // eslint-disable-line
  });

  it('AutoComplete.parseResponse should return object', () => {
    const response = {
      index: 'a',
      query: 'hest'
    };

    const expected = {hest: {a: {}}};

    const result = AutoCompleteStore.parseResponse(response, {});
    assert.isObject(result, 'Got object');
    console.log(result);
    assert.equal(JSON.stringify(result), JSON.stringify(expected), 'Result matches expectations');
  });

  it('AutoComplete.parseResponse should return object given an index equal display.creator', () => {
    const response = {
      index: 'display.creator',
      docs: ['a'],
      query: 'hest'
    };

    const result = AutoCompleteStore.parseResponse(response, {});
    assert.isObject(result, 'Got object');
    assert.property(result, response.query, 'response.query was found');
    assert.property(result[response.query], response.index, 'response.index was found');
    assert.property(result[response.query][response.index], 'label', 'label property was found');
    assert.property(result[response.query][response.index], 'data', 'data property was found');
    assert.equal(result[response.query][response.index].weight, 1, 'Found weight to equal 1');
  });

  it('AutoComplete.parseResponse should return object given an index equal display.title', () => {
    const response = {
      index: 'display.title',
      docs: ['a'],
      query: 'hest'
    };

    const result = AutoCompleteStore.parseResponse(response, {});
    assert.isObject(result, 'Got object');<commit_msg>removed console.log<commit_after>'use strict';

/**
 * @file
 * Testing the AutoComplete.store
 */
import {assert, expect} from 'chai';
import AutoCompleteStore from '../AutoComplete.store';

describe('Testing the AutoComplete Store', () => {

  it('AutoCompleteStore.addLinks should return array containing an object with an key named imageComp', () => {
    const data = [{
      pid: null
    }];
    const result = AutoCompleteStore.addLinks(data, 'display.creator');
    assert.isArray(result, 'Got array');
    assert.lengthOf(result, 1, 'Got array of length 1');
    assert.property(result[0], 'imageComp', 'Found key imageComp');
  });

  it('Should return array one containing an object with an key named imageComp', () => {
    const data = [{
      pid: 'hest'
    }];
    const result = AutoCompleteStore.addLinks(data, 'display.creator');
    assert.isArray(result, 'Got array');
    assert.lengthOf(result, 1, 'Got array of length 1');
    assert.property(result[0], 'imageComp', 'Found key imageComp');
  });

  it('AutoComplete.parseResponse should return empty object', () => {
    const response = {
      index: '',
      query: ''
    };

    const result = AutoCompleteStore.parseResponse(response, {});
    assert.isObject(result, 'Got object');
    expect(result).to.be.empty; // eslint-disable-line
  });

  it('AutoComplete.parseResponse should return object', () => {
    const response = {
      index: 'a',
      query: 'hest'
    };

    const expected = {hest: {a: {}}};

    const result = AutoCompleteStore.parseResponse(response, {});
    assert.isObject(result, 'Got object');
    assert.equal(JSON.stringify(result), JSON.stringify(expected), 'Result matches expectations');
  });

  it('AutoComplete.parseResponse should return object given an index equal display.creator', () => {
    const response = {
      index: 'display.creator',
      docs: ['a'],
      query: 'hest'
    };

    const result = AutoCompleteStore.parseResponse(response, {});
    assert.isObject(result, 'Got object');
    assert.property(result, response.query, 'response.query was found');
    assert.property(result[response.query], response.index, 'response.index was found');
    assert.property(result[response.query][response.index], 'label', 'label property was found');
    assert.property(result[response.query][response.index], 'data', 'data property was found');
    assert.equal(result[response.query][response.index].weight, 1, 'Found weight to equal 1');
  });

  it('AutoComplete.parseResponse should return object given an index equal display.title', () => {
    const response = {
      index: 'display.title',
      docs: ['a'],
      query: 'hest'
    };

    const result = AutoCompleteStore.parseResponse(response, {});
    assert.isObject(result, 'Got object');
{'fraction_non_alphanumeric': 0.1517745675049046, 'fraction_numerical': 0.0028535758872837527, 'mean_word_length': 3.7727659574468086, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5318359', 'n_tokens_mistral': 1624, 'n_tokens_neox': 1570, 'n_words': 413}