This file contains hidden or 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 {render} from 'react-dom'; | |
| import {Provider} from 'react-redux'; | |
| import {Router, browserHistory} from 'react-router'; | |
| import routes from './routes'; | |
| import configureStore from './store/configureStore'; | |
| import {syncHistoryWithStore} from 'react-router-redux'; | |
| const store = configureStore(); |
This file contains hidden or 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 {connect} from 'react-redux'; | |
| import {ProfilePage as OriginalProfilePage} from './containers/ProfilePage'; | |
| import createServerApi from './utils/serverApi'; | |
| import * as profileActions from './actions/profileActions'; | |
| import notifier from './utils/notifications'; | |
| export const createProfilePage = (serverApi, notifier) => { | |
| return connect( | |
| (state) => { | |
| return { |
This file contains hidden or 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
| onSubmit(event) { | |
| event.preventDefault(); | |
| let notifier = this.props.notifier; | |
| this.props.actions.saveProfile(this.props.profile).then((success)=>{ | |
| notifier.showSuccess(success); | |
| }, (error) => { | |
| notifier.showError(error); | |
| }) | |
| } |
This file contains hidden or 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 * as types from '../constants/actionTypes'; | |
| export function loadProfile(serverApi) { | |
| return function (dispatch) { | |
| return serverApi.getProfile().then((json) => { | |
| return dispatch({ | |
| type: types.GET_PROFILE, | |
| profile: json | |
| }); | |
| }); |
This file contains hidden or 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 {mount} from "enzyme"; | |
| import ProfileForm from "../components/ProfileForm"; | |
| import React from "react"; | |
| import {Provider} from "react-redux"; | |
| import configureStore from "../store/configureStore"; | |
| import {mockServerApi} from "../store/serverApi"; | |
| import {createProfilePage} from "../factory"; | |
| import * as models from "../models"; | |
| import {inputById, simulateChangeInField} from "../utils/testHelper"; | |
| import notifier from "../utils/notifications"; |
This file contains hidden or 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
| componentDidMount() { | |
| let notifier = this.props.notifier; | |
| notifier.startLoad(); | |
| this.props.actions.loadProfile().then(() => { | |
| notifier.stopLoad(); | |
| }); | |
| } |
This file contains hidden or 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 * as types from '../constants/actionTypes'; | |
| export function loadProfile(serverApi) { | |
| return function (dispatch) { | |
| return serverApi.getProfile().then((json) => { | |
| return dispatch({ | |
| type: types.GET_PROFILE, | |
| profile: json | |
| }); | |
| }); |
This file contains hidden or 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 * as actionTypes from '../constants/actionTypes'; | |
| import initialState from './initialState'; | |
| export default function profileReducer(profile = initialState.profile, action) { | |
| if (action.type == actionTypes.GET_PROFILE) { | |
| return Object.assign({}, profile, action.profile); | |
| } | |
| return profile; | |
| } |
This file contains hidden or 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
| it("saves the profile in the backend", (done) => { | |
| simulateChangeInPhone(change); | |
| let actualProfile; | |
| spyNotifier.slowOperationFinished = () => { | |
| expect(actualProfile.phone).toEqual(change); | |
| done(); | |
| }; | |
| stubApi.saveProfile = (profile) => { | |
| actualProfile = profile; | |
| return Promise.resolve({message: 'Success'}); |
This file contains hidden or 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
| it("saves the profile in the backend", (done) => { | |
| simulateChangeInPhone(change); | |
| let savedProfile = spyOnSaveProfile(); | |
| eventually(() => { | |
| expect(savedProfile.phone).toEqual(change); | |
| }, done); | |
| saveProfileButton().simulate("click"); | |
| }); |
OlderNewer