Commit 31c6b075 authored by Martin Fahl's avatar Martin Fahl

removes code for deleting items from server

parent abcaaaad
......@@ -2,19 +2,6 @@ import * as actions from "../itemsActions"
import * as types from "../../constants/ActionTypes"
describe("itemsActions", () => {
it("should create an action to add an item locally", () => {
const id = "a23"
const name = "Coconut"
const quantity = 3
const expectedAction = {
type: types.ITEM_ADDED,
id,
name,
quantity
}
expect(actions.itemAdded(id, name, quantity)).toEqual(expectedAction)
})
it("should create an action to delete an item locally", () => {
const id = "aaaa-bbb23"
const expectedAction = {
......
......@@ -39,18 +39,5 @@ describe("async actions", () => {
await store.dispatch(actions.deleteItem(id))
return expect(store.getActions()).toEqual(expectedActions)
})
it("creates ITEM_ADDED when adding an item has been done", async () => {
const item = { id: 25, name: "Hammer", quantity: 10}
mockAxios
.onPost("/api/items").replyOnce(200, item)
const expectedActions = [
{ type: types.ITEM_ADDED, ...item}
]
const store = mockStore({ items: [] })
await store.dispatch(actions.addItem(item.name, item.quantity))
return expect(store.getActions()).toEqual(expectedActions)
})
})
\ No newline at end of file
......@@ -8,7 +8,7 @@ export const addItem = (id, name, quantity) => ({
quantity
})
export const itemDeleted = id => ({
export const deleteItem = id => ({
type: types.ITEM_DELETED,
id
})
......@@ -27,8 +27,4 @@ export const itemsLoaded = (items) => ({
export const getAllItems = () => dispatch => {
return Axios.get("/api/items").then((response) => dispatch(itemsLoaded(response.data)))
}
export const deleteItem = (id) => dispatch => {
return Axios.delete("/api/items/"+id).then(dispatch(itemDeleted(id)))
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment