import React from 'react';
import { shallow, render } from 'enzyme';
import { expect } from 'chai';

// see: https://github.com/mochajs/mocha/issues/1847
const { describe, it } = global;

import Preview from '../Preview';


describe('<Preview />', () => {

  it('renders a block with preview css class', () => {
    const wrapper = shallow(<Preview raw={""} />);
    expect(wrapper.find('.preview')).to.have.length(1);
  });

  it('renders content', () => {
    const wrapper = render(<Preview raw={"foo"} />);
    expect(wrapper.find('.rendered').text()).to.contain('foo');
  });

  it('converts markdown into HTML', () => {
    const wrapper = render(<Preview raw={"*italic*"} />);
    expect(wrapper.find('.rendered').html()).to.contain('<em>italic</em>');
  });

  it('converts Emoji', () => {
    const wrapper = render(<Preview raw={" :)"} />);
    expect(wrapper.find('.rendered').html()).to.contain(
      '<img align="absmiddle" alt=":smile:" class="emoji" src="https://github.global.ssl.fastly.net/images/icons/emoji//smile.png" title=":smile:"></p>'
    );
  });
});

@@ -1052,11 +1052,350 @@
 e:%22%3E
+'%0A    );%0A  %7D);%0A%0A  it('highlights code blocks', () =%3E %7B%0A    const wrapper = render(%3CPreview raw=%7B%22%60%60%60python%5Cnprint()%60%60%60%22%7D /%3E);%0A    expect(wrapper.find('.rendered').html()).to.contain(%0A      '%3Cpre%3E%3Ccode class=%22lang-python%22%3E%3Cspan class=%22hljs-function%22%3E%3Cspan class=%22hljs-title%22%3Eprint%3C/span%3E%3Cspan class=%22hljs-params%22%3E()%3C/span%3E%3C/span%3E%5Cn%3C/code%3E
 %3C/p
+re
 %3E'%0A 

Add test for highlight.js rendering