Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Lelith
Last active April 18, 2020 08:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lelith/19089b956cc934a1de8bb6e8847a9323 to your computer and use it in GitHub Desktop.
Save Lelith/19089b956cc934a1de8bb6e8847a9323 to your computer and use it in GitHub Desktop.
Snapshot Tesz
/* src/components/Counter/test/Counter.test.js */
import React from 'react'
import Counter from '../';
import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json'
const callBackFunc = jest.fn();
const counterComponent = shallow(<Counter callBack = {callBackFunc} />);
describe('<counterComponent />', () => {
(...)
it('turns red on negative amounts', () => {
counterComponent.setState({amount:-2});
expect(toJson(counterComponent)).toMatchSnapshot();
expect(counterComponent.find("[data-test='counterComponent']")
.first().hasClass('counter--negative')).toBe(true);
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment