Skip to content

Instantly share code, notes, and snippets.

@jasongaare
Last active June 1, 2017 01:39
Show Gist options
  • Save jasongaare/1a6f338ffd96c289732ecc1b6664f38d to your computer and use it in GitHub Desktop.
Save jasongaare/1a6f338ffd96c289732ecc1b6664f38d to your computer and use it in GitHub Desktop.
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,
open_to_camera: true,
},
};
import CameraSettings from 'components/menu/CameraSettings';
describe('Testing CameraSettings', () => {
it('calls actions as expected when toggling switches', () => {
const wrapper = shallow(
<CameraSettings />,
{ context: { store: mockStore(initialState) } },
);
const render = wrapper.dive();
const saveToPhoneSpy = sinon.spy(NativeModules.PhotoActions, 'saveToPhone');
render.find('Switch').forEach(child => {
child.simulate('valueChange');
});
expect(saveToPhoneSpy.calledOnce).toBe(true);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment