// jshint esversion: 6
'use strict';

import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import React from 'react';
import { List } from './List';
import Store from '../../../data/Store';
import { mount } from '../../../../build/enzyme';

var MyList =
/*#__PURE__*/
function (_List) {
  _inheritsLoose(MyList, _List);

  function MyList() {
    return _List.apply(this, arguments) || this;
  }

  var _proto = MyList.prototype;

  _proto.renderItem = function renderItem(item, index) {
    return React.createElement("span", {
      key: index
    }, item.value);
  };

  _proto.render = function render() {
    var r = _List.prototype.render.call(this);

    return React.createElement("div", null, r);
  };

  return MyList;
}(List);

var storeFields = [{
  id: 'id',
  type: 'number'
}, {
  id: 'value',
  type: 'string'
}];
var storeItems = [{
  id: 1,
  value: 'Alpha'
}, {
  id: 2,
  value: 'Bravo'
}, {
  id: 3,
  value: 'Charlie'
}];
describe('List', function () {
  it('renders list of items', function () {
    var store = new Store({
      fields: storeFields
    });
    store.setItems(storeItems);
    var props = {
      store: store
    };
    var wrapper = mount(React.createElement(MyList, props));
    var actualTexts = wrapper.find('span').map(function (item) {
      return item.text();
    });
    var expectedText = storeItems.map(function (item) {
      return item.value;
    });
    expect(actualTexts).toEqual(expectedText);
  });
  it('renders empty message', function () {
    var store = new Store({
      fields: storeFields
    });
    store.setItems([]);
    var props = {
      noResultsText: 'no results',
      store: store
    };
    var wrapper = mount(React.createElement(MyList, props));
    var actualText = wrapper.text();
    var expectedText = props.noResultsText;
    expect(actualText).toBe(expectedText);
  });
});