<commit_before>import * as React from "react";
import {mount, spyLifecycle, shallow} from "enzyme";
import * as TestUtils from 'react-addons-test-utils';
import {RefinementListFilter} from "../src/RefinementListFilter.tsx";
import {SearchkitProvider, SearchkitManager } from "../../../../../core";

describe("Refinement List Filter tests", () => {

  beforeEach(() => {

    this.searchkit = new SearchkitManager("localhost:9200", {useHistory:true})
    this.searchkit.translateFunction = (key)=> {
      return {
        "test option 1":"test option 1 translated"
      }[key]
    }

    this.wrapper = mount(
      <RefinementListFilter
        field="test" id="test" title="test"
        searchkit={this.searchkit} />
    );

    this.searchkit.setResults({
      aggregations: {
        test: {
          test: {
            buckets:[
              {key:"test option 1", doc_count:1},
              {key:"test option 2", doc_count:2},
              {key:"test option 3", doc_count:3}
            ]
          },
          "test.count":{
            value:3
          }
        }
      }
    })
  });

  it('renders correctly', () => {
    expect(this.wrapper.find(".refinement-list__header").text()).toBe("test")
    expect(this.wrapper.find(".refinement-list__options").children().map(
      (n) => {
        return n.find(".refinement-list-option__text").text()
      })).toEqual([ 'test option 1 translated', 'test option 2', 'test option 3' ])
  });

});<commit_msg>unit test accessor options<commit_after>import * as React from "react";
import {mount, spyLifecycle, shallow} from "enzyme";
import * as TestUtils from 'react-addons-test-utils';
import {RefinementListFilter} from "../src/RefinementListFilter.tsx";
import {SearchkitProvider, SearchkitManager } from "../../../../../core";

describe("Refinement List Filter tests", () => {

  beforeEach(() => {

    this.searchkit = new SearchkitManager("localhost:9200", {useHistory:true})
    this.searchkit.translateFunction = (key)=> {
      return {
        "test option 1":"test option 1 translated"
      }[key]
    }

    this.wrapper = mount(
      <RefinementListFilter
        field="test" id="test" title="test"
        searchkit={this.searchkit} />
    );

    this.searchkit.setResults({
      aggregations: {
        test: {
          test: {
            buckets:[
              {key:"test option 1", doc_count:1},
              {key:"test option 2", doc_count:2},
              {key:"test option 3", doc_count:3}
            ]
          },
          "test.count":{
            value:3
          }
        }
      }
    })
  });

  it('renders correctly', () => {
    expect(this.wrapper.find(".refinement-list__header").text()).toBe("test")
    expect(this.wrapper.find(".refinement-list__options").children().map(
      (n) => {
        return n.find(".refinement-list-option__text").text()
      })).toEqual([ 'test option 1 translated', 'test option 2', 'test option 3' ])
  });

  it("should configure accessor correctly", ()=> {
    let options = this.searchkit.accessors.getAccessors()[0].options
    expect(options).toEqual({
      "id": "test",
      "title": "test",
      "size": 50,
      "facetsPerPage": 50,
      "operator":undefined,
      "translations":undefined
    })

  })

});
{'fraction_non_alphanumeric': 0.16819571865443425, 'fraction_numerical': 0.011314984709480122, 'mean_word_length': 2.4577167019027484, 'pattern_counts': {'":': 10, '<': 5, '<?xml version=': 0, '>': 16, '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': '1698923', 'n_tokens_mistral': 1003, 'n_tokens_neox': 962, 'n_words': 197}