it('should create DELETE_TASK_ERROR', () => { const expectedActions = [ {type: types.DELETE_TASK}, {type: types.DELETE_TASK_ERROR, error: true, payload: {}, meta: {id: 1}} ]; const store = createMockStore({list: []}, expectedActions, [middleware]); whenDELETE.respond(403, {}); store.dispatch(deleteTask({id: 1})); httpBackend.flush(); });
it('should create DELETE_TASK_SUCCESS', () => { const expectedActions = [ {type: types.DELETE_TASK}, {type: types.DELETE_TASK_SUCCESS, payload: undefined, meta: {id: 1}} ]; const store = createMockStore({list: []}, expectedActions, [middleware]); whenDELETE.respond(200); store.dispatch(deleteTask({id: 1})); httpBackend.flush(); });
it('should create CREATE_TASK_ERROR', () => { const expectedActions = [ {type: types.CREATE_TASK}, {type: types.CREATE_TASK_ERROR, error: true, payload: {}, meta: undefined} ]; const store = createMockStore({list: []}, expectedActions, [middleware]); whenPOST.respond(403, {}); store.dispatch(createTask('create task')); httpBackend.flush(); });
it('should create FETCH_TASKS_ERROR', () => { const expectedActions = [ {type: types.FETCH_TASKS}, {type: types.FETCH_TASKS_ERROR, error: true, payload: {}, meta: undefined} ]; const store = createMockStore({list: []}, expectedActions, [middleware]); whenGET.respond(403, {}); store.dispatch(fetchTasks()); httpBackend.flush(); });
it('should create FETCH_TASKS_SUCCESS', () => { const expectedActions = [ {type: types.FETCH_TASKS}, {type: types.FETCH_TASKS_SUCCESS, payload: [], meta: undefined} ]; const store = createMockStore({list: []}, expectedActions, [middleware]); whenGET.respond(200, []); store.dispatch(fetchTasks()); httpBackend.flush(); });
it('should create CREATE_TASK_SUCCESS', () => { const task = {completed: false, id: 1, title: 'create task'}; const expectedActions = [ {type: types.CREATE_TASK}, {type: types.CREATE_TASK_SUCCESS, payload: task, meta: undefined} ]; const store = createMockStore({list: []}, expectedActions, [middleware]); whenPOST.respond(200, task); store.dispatch(createTask('create task')); httpBackend.flush(); });