import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
import { tips } from '../tips';
import { useTablePipeline } from '../../pipeline';
import { mount } from 'enzyme';
import { renderHook } from '@testing-library/react-hooks';
import React from 'react';
var dataSource = [{
  id: '1',
  prov: '湖北省',
  confirm: 54406,
  cure: 4793,
  dead: 1457,
  t: '2020-02-15 19:52:02'
}, {
  id: '2',
  prov: '广东省',
  confirm: 1294,
  cure: 409,
  dead: 2,
  t: '2020-02-15 19:52:02'
}, {
  id: '3',
  prov: '河南省',
  confirm: 1212,
  cure: 390,
  dead: 13,
  t: '2020-02-15 19:52:02'
}, {
  id: '4',
  prov: '浙江省',
  confirm: 1000,
  cure: 428,
  dead: 0,
  t: '2020-02-15 19:52:02'
}, {
  id: '5',
  prov: '湖南省',
  confirm: 1000,
  cure: 417,
  dead: 2,
  t: '2020-02-15 19:52:02'
}];
var columns = [{
  code: 'prov',
  name: '省份',
  width: 150,
  features: {
    tips: '省份信息'
  }
}, {
  code: 'confirm',
  name: '确诊',
  width: 100,
  align: 'right',
  features: {
    tips: '确诊数量'
  }
}, {
  code: 'cure',
  name: '治愈',
  width: 100,
  align: 'right'
}, {
  code: 'dead',
  name: '死亡',
  width: 100,
  align: 'right'
}, {
  code: 't',
  name: '更新时间',
  width: 180
}];

function Tooltip(_ref) {
  var title = _ref.title,
      children = _ref.children;
  return /*#__PURE__*/React.createElement("div", null, title);
}

describe('tips 单元测试', function () {
  var newPipeline = null;
  beforeEach(function () {
    var _renderHook = renderHook(function () {
      return useTablePipeline({
        primaryKey: 'id',
        components: {
          Tooltip: Tooltip
        }
      }).input({
        dataSource: dataSource,
        columns: columns
      });
    }),
        result = _renderHook.result;

    var tablePipeline = result.current;
    newPipeline = tips()(tablePipeline);
  });
  afterEach(function () {
    newPipeline = null;
  });
  it('初始化时存在Tooltip组件', function () {
    var col = newPipeline.getColumns();
    var wrapper = mount(col[0].title);
    expect(_findInstanceProperty(wrapper).call(wrapper, 'Tooltip').length).toBe(1);
  });
  it('不传Tooltip', function () {
    var _renderHook2 = renderHook(function () {
      return useTablePipeline({
        primaryKey: 'id'
      }).input({
        dataSource: dataSource,
        columns: columns
      });
    }),
        result = _renderHook2.result;

    var tablePipeline = result.current;
    expect(function () {
      return tips()(tablePipeline);
    }).toThrow(Error);
  });
});