Skip to content

Instantly share code, notes, and snippets.

View jasongaare's full-sized avatar
😋
Hungry

Jason Gaare jasongaare

😋
Hungry
View GitHub Profile
import React from 'react';
import { shallow } from 'enzyme';
import mockStore from 'redux-mock-store';
import sinon from 'sinon';
import { NativeModules } from 'react-native';
const initialState = {
preferences: {
save_photos_locally: true,
it('calls actions as expected when toggling switches', () => {
const wrapper = shallow(
<CameraSettings />,
{ context: { store: mockStore(initialState) } },
);
const render = wrapper.dive();
render.find('Switch').forEach(child => {
child.simulate('valueChange');
});
});
import React from 'react';
import { shallow } from 'enzyme';
import configureStore from 'redux-mock-store';
// imported as a connected component!
import CameraSettings from 'components/menu/CameraSettings';
const middlewares = []; // you can mock any middlewares here if necessary
const mockStore = configureStore(middlewares);
import React from 'react';
import { shallow } from 'enzyme';
import { ReassignLocationMenu } from 'components/menu/ReassignLocationMenu';
describe('Testing ReassignLocationMenu component', () => {
it('renders as expected', () => {
const wrapper = shallow(
<ReassignLocationMenu count={2} />
);
expect(wrapper).toMatchSnapshot();
@jasongaare
jasongaare / Login-page-test.js
Created May 24, 2017 18:14
Our first React Native test using Jest
// __tests__/Login-page-test.js
import 'react-native';
import React from 'react';
import Login from 'components/sessions/login';
import renderer from 'react-test-renderer';
it('renders correctly', () => {
const tree = renderer.create(
<Login />