Last active
June 1, 2017 01:39
-
-
Save jasongaare/1a6f338ffd96c289732ecc1b6664f38d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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