import { expect } from 'chai';
import { shallow, mount } from 'enzyme';
import React from 'react';
import { MemoryRouter as Router } from 'react-router-dom';
import Posts from '../../src/js/components/Posts';
import PostPreview from '../../src/js/components/PostPreview';

describe('<Posts/>', () => {
  const posts = [
    { id: 0, title: 'First Post', tags: ['js'] },
    { id: 1, title: 'Second Post' },
  ];

  it('renders list of posts', () => {
    const result = shallow(<Posts posts={posts} />);
    expect(result.find(PostPreview).length).to.eq(2);
  });

  it('passes tag to <PostPreview>', () => {
    const result = mount(<Router><Posts tag="js" posts={posts} /></Router>);
    expect(result.find('.tags__tag_active').text()).to.eq('js');
  });

  it('renders message when there are no posts', () => {
    const result = shallow(<Posts posts={[]} />);
    expect(result.contains(<p>No posts found.</p>)).to.eq(true);
  });
});

@@ -627,16 +627,23 @@
 = mount(
+%0A      
 %3CRouter%3E
@@ -683,16 +683,22 @@
 /Router%3E
+,%0A    
 );%0A    e
@@ -714,39 +714,76 @@
 ult.
-find('.tags__tag_active').text(
+contains(%0A      %3CPostPreview activeTag=%22js%22 post=%7Bposts%5B0%5D%7D /%3E,%0A    
 )).t
@@ -787,20 +787,20 @@
 ).to.eq(
-'js'
+true
 );%0A  %7D);

Use .contains() for testing in Posts.spec.js