Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- it('creates FETCH_TODOS_SUCCESS when fetching todos has been done', (done) => {
- nock('http://example.com/')
- .get('/todos')
- .reply(200, { todos: ['do something'] })
- const expectedActions = [
- { type: types.FETCH_TODOS_REQUEST },
- { type: types.FETCH_TODOS_SUCCESS, body: { todos: ['do something'] } }
- ]
- const store = mockStore({ todos: [] }, expectedActions, done)
- store.dispatch(actions.fetchTodos())
- })
- it('should request a password reset, and then return success on 200', (done) => {
- nock('http://localhost:8080/')
- .post('password-reset-requests')
- .reply(200);
- var email = "test@email.com";
- const expectedActions=[
- {type: REQUEST_ADD_PASSWORD_RESET_REQUEST},
- {type: REQUEST_ADD_PASSWORD_RESET_REQUEST_SUCCESS}
- ];
- const store = mockStore({}, expectedActions, done);
- store.dispatch(Actions.addPasswordResetRequest());
- export default function addPasswordResetRequest(email){
- return dispatch => {
- dispatch(requestAddPasswordResetRequest(email));
- return addPasswordResetRequestAPI(email)
- .then(() =>{
- dispatch(requestAddPasswordResetRequestSuccess());
- })
- .catch((error) => {
- dispatch(requestAddPasswordResetRequestFailure(error));
- });
- };
- }
- export const addPasswordResetRequestAPI = (email) => {
- return fetch(
- SETTINGS.API_ROOT + '/password-reset-requests',
- {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify({
- email: email,
- code: NC_SETTINGS.GROUP.code
- })
- }
- )
- .then(handleResponse);
- };
- it('should request a password reset, and then return success on 200', (done) => {
- nock('http://localhost:8080/')
- .post('password-reset-requests')
- .reply(200);
- Actions.addPasswordResetRequest = spy(() => {
- return ([
- {type: REQUEST_ADD_PASSWORD_RESET_REQUEST},
- {type: REQUEST_ADD_PASSWORD_RESET_REQUEST_SUCCESS}
- ]
- );
- });
- var email = "test@email.com";
- const expectedActions=[
- {type: REQUEST_ADD_PASSWORD_RESET_REQUEST},
- {type: REQUEST_ADD_PASSWORD_RESET_REQUEST_SUCCESS}
- ];
- const store = mockStore({}, expectedActions, done);
- store.dispatch(Actions.addPasswordResetRequest());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement