diff --git a/.idea/workspace.xml b/.idea/workspace.xml index c033440..8111736 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,18 +1,15 @@ - - - - + + - + - - + @@ -27,33 +24,35 @@ - - + + - - - + + + + + - - + + - - + + - + - - + + - - + + @@ -72,8 +71,8 @@ - - + + @@ -91,31 +90,33 @@ - - + + - - - + + + + + - - + + - - + + - - + + - - + + @@ -124,10 +125,10 @@ - - + + - + @@ -137,8 +138,6 @@ - Component - bigSrc getBigPhoto currentPhoto previousIndex @@ -167,6 +166,8 @@ id="next" actions nextRandom + Enzyme.configure({ adapter: new Adapter() }); + console @@ -204,15 +205,16 @@ - - - - + + + + + @@ -496,7 +498,7 @@ - + 1507610877879 @@ -575,11 +577,18 @@ 1508214633939 - + + 1508224843443 + + + + 1508224843443 + + - + @@ -623,7 +632,8 @@ - + + @@ -632,14 +642,6 @@ - - - - - - - - @@ -878,16 +880,6 @@ - - - - - - - - - - @@ -912,16 +904,6 @@ - - - - - - - - - - @@ -946,16 +928,6 @@ - - - - - - - - - - @@ -980,41 +952,79 @@ - + - - + + + + + + + + + + - + - + - - + + + + - + - + + + + + + + + + + + - + + + + + + + + + + + - - + + - + + + + + + + + + \ No newline at end of file diff --git a/src/App.test.js b/src/App.test.js index 14c0269..6d0728b 100644 --- a/src/App.test.js +++ b/src/App.test.js @@ -1,3 +1,6 @@ +// import raf from './setupTests'; +//https://github.com/facebookincubator/create-react-app/issues/3199 + import React from 'react'; import { mount } from 'enzyme'; import { mountToJson } from 'enzyme-to-json'; @@ -6,6 +9,7 @@ import store from './store/index'; import * as random from './utilities/random'; import App from './App'; + it('renders correctly', () => { const app = mount( diff --git a/src/__snapshots__/App.test.js.snap b/src/__snapshots__/App.test.js.snap index 6fb2795..a7e0fca 100644 --- a/src/__snapshots__/App.test.js.snap +++ b/src/__snapshots__/App.test.js.snap @@ -1,1325 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`can navigate through the photos 1`] = ` - - - - - - - - - - PhotoBooth! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Previous - - - - - Next - - - - - Random - - - - - - - - - Baseball - - - - - - - - - - - -`; - -exports[`can navigate through the photos 2`] = ` - - - - - - - - - - PhotoBooth! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Previous - - - - - Next - - - - - Random - - - - - - - - - Surf - - - - - - - - - - - -`; - -exports[`can navigate through the photos 3`] = ` - - - - - - - - - - PhotoBooth! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Previous - - - - - Next - - - - - Random - - - - - - - - - Baseball - - - - - - - - - - - -`; - -exports[`can navigate through the photos 4`] = ` - - - - - - - - - - PhotoBooth! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Previous - - - - - Next - - - - - Random - - - - - - - - - Baseball - - - - - - - - - - - -`; - exports[`photo booth navigates to next photo 1`] = ` { - console.log("dafdas sdf") this.props.store.dispatch(actions.nextPhoto()); } diff --git a/src/components/index.test.js b/src/components/index.test.js index 2626002..ec59f2a 100644 --- a/src/components/index.test.js +++ b/src/components/index.test.js @@ -1,9 +1,9 @@ +// import raf from '../setupTests'; + import React from 'react'; import { shallow } from 'enzyme'; import {loadPhotos} from '../actions'; -import store from '../store'; - import Index from './index'; describe('When photo booth', () => { diff --git a/src/reducers/random.js b/src/reducers/random.js index 2865ff9..095e48a 100644 --- a/src/reducers/random.js +++ b/src/reducers/random.js @@ -5,7 +5,6 @@ function selectPhoto(index, allPhotos){ } export default function (state, _action){ - console.log(nextRandom()) return Object.assign({}, state, { currentPhoto: selectPhoto( nextRandom(state.currentPhoto.index, state.allPhotos.length), diff --git a/src/setupTests.js b/src/setupTests.js index 4dff30e..45e65e8 100644 --- a/src/setupTests.js +++ b/src/setupTests.js @@ -1,8 +1,18 @@ -import Enzyme from "enzyme"; -import Adapter from "enzyme-adapter-react-16"; +import raf from './tempPolyfills' +import Enzyme, { shallow, render, mount } from 'enzyme'; +import Adapter from 'enzyme-adapter-react-16'; +import toJson from 'enzyme-to-json'; +// React 16 Enzyme adapter Enzyme.configure({ adapter: new Adapter() }); -global.requestAnimationFrame = function(callback) { - setTimeout(callback, 0); +// Make Enzyme functions available in all test files without importing +global.shallow = shallow; +global.render = render; +global.mount = mount; +global.toJson = toJson; + +// Fail tests on any warning +console.error = message => { + throw new Error(message); }; \ No newline at end of file diff --git a/src/tempPolyfills.js b/src/tempPolyfills.js new file mode 100644 index 0000000..8858a9d --- /dev/null +++ b/src/tempPolyfills.js @@ -0,0 +1,5 @@ +const raf = global.requestAnimationFrame = (cb) => { + setTimeout(cb, 0) +} + +export default raf; \ No newline at end of file