Skip to content

Commit

Permalink
adding snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
lambrugeorge committed Jun 10, 2024
1 parent f7a8bfa commit a1f99c0
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 287 deletions.
26 changes: 0 additions & 26 deletions src/actions.test.js

This file was deleted.

2 changes: 2 additions & 0 deletions src/components/Card.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import React from 'react';
import { shallow, mount, render } from 'enzyme'


const Card = ({ name, email, id }) => {
return (
Expand Down
8 changes: 4 additions & 4 deletions src/components/Card.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { shallow } from 'enzyme';
import { shallow, mount, render } from 'enzyme'
import Card from './Card';

it('renders without crashing', () => {
expect(shallow(<Card/>)).toMatchSnapshot();
});
it('expect to render Card component', () => {
expect(shallow(<Card />)).toMatchSnapshot();
})
23 changes: 12 additions & 11 deletions src/components/CardList.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import React from "react";
import { shallow } from 'enzyme';
import CardList from "./CardList";
import { shallow, mount, render } from 'enzyme'
import CardList from './CardList';

const filteredRobots = [{
it('expect to render CardList component', () => {
const mockRobots = [
{
id: 1,
name: "Leanne Graham",
username: 'Bret',
email: 'Sincere@april.bz'
}]

it('renders without crashing', () => {
expect(shallow(<CardList robots={filteredRobots}/>)).toMatchSnapshot();
});
name: 'John Snow',
username: 'JohnJohn',
email: 'john@gmail.com'
}
]
expect(shallow(<CardList robots={mockRobots}/>)).toMatchSnapshot();
})
22 changes: 22 additions & 0 deletions src/components/CounterButton.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from "react";
import { shallow } from 'enzyme';
import CounterButton from './CounterButton';

it('expect to render CounterButton component', () => {
const mockColor = 'red';
expect(shallow(<CounterButton color={mockColor} />)).toMatchSnapshot();
});

it('correctly increments the counter', () => {
const mockColor = 'red';
const wrapper = shallow(<CounterButton color={mockColor} />);

wrapper.find('[id="counter"]').simulate('click');
wrapper.find('[id="counter"]').simulate('click');
expect(wrapper.state('count')).toEqual(2);
wrapper.find('[id="counter"]').simulate('click');
expect(wrapper.state('count')).toEqual(3);
wrapper.find('[id="counter"]').simulate('keypress');
expect(wrapper.state('count')).toEqual(3);
expect(wrapper.props().color).toEqual('red');
});
17 changes: 0 additions & 17 deletions src/components/CounterButton.text.js

This file was deleted.

75 changes: 0 additions & 75 deletions src/components/MainPage.test.js

This file was deleted.

15 changes: 1 addition & 14 deletions src/components/__snapshots__/Card.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders without crashing 1`] = `
<div
className="tc grow bg-light-green br3 pa3 ma2 dib bw2 shadow-5"
>
<img
alt="robots"
src="https://robohash.org/undefined?size=200x200"
/>
<div>
<h2 />
<p />
</div>
</div>
`;
exports[`expect to render Card component 1`] = `ShallowWrapper {}`;
11 changes: 1 addition & 10 deletions src/components/__snapshots__/CardList.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders without crashing 1`] = `
<div>
<Card
email="Sincere@april.biz"
id={1}
key="0"
name="Leanne Graham"
/>
</div>
`;
exports[`expect to render CardList component 1`] = `ShallowWrapper {}`;
20 changes: 1 addition & 19 deletions src/components/__snapshots__/CounterButton.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`correnctly increments the counter 1`] = `
<button
id="counter"
onClick={[Function]}
>
Count:
0
</button>
`;

exports[`renders without crashing 1`] = `
<button
id="counter"
onClick={[Function]}
>
Count:
0
</button>
`;
exports[`expect to render CounterButton component 1`] = `ShallowWrapper {}`;
17 changes: 0 additions & 17 deletions src/components/__snapshots__/MainPage.test.js.snap

This file was deleted.

92 changes: 0 additions & 92 deletions src/reducers.test.js

This file was deleted.

3 changes: 1 addition & 2 deletions src/setupTests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { configure } from 'enzyme';
// import Adapter from 'enzyme-adapter-react-16'; only use for React 16
// import Adapter from '@wojtekmaj/enzyme-adapter-react-17'; only use for React 17

import Adapter from '@cfaester/enzyme-adapter-react-18';

configure({ adapter: new Adapter() });

0 comments on commit a1f99c0

Please sign in to comment.