import ReactDOM from 'react-dom';
import React from 'react';
import { shallow, render } from 'enzyme';
import { expect } from 'chai';
import { Text } from 'recharts';

describe('<Text />', () => {
  it('Does not wrap long text if enough width', () => {
    const wrapper = shallow(
      <Text width={200}>This is really long text</Text>
    );

    expect(wrapper.instance().state.wordsByLines.length).to.equal(1);
  });

  it('Wraps long text if not enough width', () => {
    const wrapper = shallow(
      <Text width={125}>This is really long text</Text>
    );

    expect(wrapper.instance().state.wordsByLines.length).to.equal(2);
  });

  it('Wraps long text if styled and not enough room', () => {
    const wrapper = shallow(
      <Text width={200} style={{ fontSize: '32px' }}>This is really long text</Text>
    );

    expect(wrapper.instance().state.wordsByLines.length).to.equal(2);
  });

  it('Does not perform word length calculation if width or fit props not set', () => {
    const wrapper = shallow(
      <Text>This is really long text</Text>
    );

    expect(wrapper.instance().state.wordsByLines.length).to.equal(1);
    expect(wrapper.instance().state.wordsByLines[0].width).to.equal(undefined);
  });
});

@@ -294,20 +294,54 @@
  width=%7B
-2
+3
 00%7D
+ style=%7B%7B fontFamily: 'Courier' %7D%7D
 %3EThis is
@@ -554,11 +554,45 @@
 th=%7B
-125
+200%7D style=%7B%7B fontFamily: 'Courier' %7D
 %7D%3ETh
@@ -742,15 +742,26 @@
 led 
-and not
+but would have had
  eno
@@ -819,33 +819,33 @@
    %3CText width=%7B
-2
+3
 00%7D style=%7B%7B fon
@@ -856,12 +856,34 @@
 e: '
-32px
+2em', fontFamily: 'Courier
 ' %7D%7D

Set fontFamily on <Text> tests to guarantee consistent regardless of environment (hopefully fix failures in CI)