import { expect } from 'chai';
import { mount, shallow } from 'enzyme';
import React from 'react';
import Post from '../../src/js/components/Post';

describe('<Post/>', () => {
  const post = {
    id: 0,
    title: 'Test Post',
    content: 'empty',
    description: 'empty',
    author: 'bot',
    slug: 'test-post',
    tags: ['test', 'react'],
  };

  it('renders post title', () => {
    const result = shallow(<Post post={post} />);
    expect(result.find('.post__title').text()).to.eq('Test Post');
  });

  it('renders post metadata', () => {
    const result = mount(<Post post={post} />);
    expect(result.find('.post__meta').text()).to.eq('  a few seconds ago');
  });

  it('renders post image', () => {
    const postWithImage = { ...post, img: 'image.png' };
    const result = shallow(<Post post={postWithImage} />);
    expect(result.find('.post__image').length).to.eq(1);
  });

  it('renders no image if missing', () => {
    const result = mount(<Post post={post} />);
    expect(result.find('.post__image').length).to.eq(0);
  });
});

import { expect } from 'chai';
import { mount } from 'enzyme';
import React from 'react';
import Post from '../../src/js/components/Post';

describe('<Post/>', () => {
  const post = {
    id: 0,
    title: 'Test Post',
    content: 'empty',
    description: 'empty',
    author: 'bot',
    slug: 'test-post',
    tags: ['test', 'react'],
  };

  it('renders post title', () => {
    const result = mount(<Post post={post} />);
    expect(result.find('.post__title').text()).to.eq('Test Post');
  });

  it('renders post metadata', () => {
    const result = mount(<Post post={post} />);
    expect(result.find('.post__meta').text()).to.eq('  a few seconds ago');
  });

  it('renders post image', () => {
    const postWithImage = { ...post, img: 'image.png' };
    const result = mount(<Post post={postWithImage} />);
    expect(result.find('.post__image').length).to.eq(1);
  });

  it('renders no image if missing', () => {
    const result = mount(<Post post={post} />);
    expect(result.find('.post__image').length).to.eq(0);
  });
});

--- 
+++ 
@@ -1,5 +1,5 @@
 import { expect } from 'chai';
-import { mount, shallow } from 'enzyme';
+import { mount } from 'enzyme';
 import React from 'react';
 import Post from '../../src/js/components/Post';
 
@@ -15,7 +15,7 @@
   };
 
   it('renders post title', () => {
-    const result = shallow(<Post post={post} />);
+    const result = mount(<Post post={post} />);
     expect(result.find('.post__title').text()).to.eq('Test Post');
   });
 
@@ -26,7 +26,7 @@
 
   it('renders post image', () => {
     const postWithImage = { ...post, img: 'image.png' };
-    const result = shallow(<Post post={postWithImage} />);
+    const result = mount(<Post post={postWithImage} />);
     expect(result.find('.post__image').length).to.eq(1);
   });
 
Replace `mount` calls with `shallow` in <Post> tests
