Commit 6640b383 authored by Martin Fahl's avatar Martin Fahl

removes test for update item and removes code for add item

parent 483d7233
......@@ -33,16 +33,4 @@ describe("itemsActions", () => {
expect(actions.itemsLoaded(items)).toEqual(expectedAction)
})
it("should create an action to signal that the items have been updated", () => {
const id = 1
const name = "Butter"
const quantity = 98
const expectedAction = {
type: types.ITEM_UPDATED,
id,
name,
quantity
}
expect(actions.itemUpdated(id, name, quantity)).toEqual(expectedAction)
})
})
\ No newline at end of file
......@@ -53,18 +53,4 @@ describe("async actions", () => {
await store.dispatch(actions.addItem(item.name, item.quantity))
return expect(store.getActions()).toEqual(expectedActions)
})
it("creates ITEM_UPDATED when an item has been updated", async () => {
const item = { id: 25, name: "Hammer", quantity: 10}
mockAxios
.onPut("/api/items/"+item.id).replyOnce(204, item)
const expectedActions = [
{ type: types.ITEM_UPDATED, ...item}
]
const store = mockStore({ items: [item] })
await store.dispatch(actions.updateItem(item.id, item.name, item.quantity))
return expect(store.getActions()).toEqual(expectedActions)
})
})
\ No newline at end of file
import * as types from "../constants/ActionTypes"
import Axios from "axios"
export const itemAdded = (id, name, quantity) => ({
export const addItem = (id, name, quantity) => ({
type: types.ITEM_ADDED,
id,
name,
......@@ -29,10 +29,6 @@ export const getAllItems = () => dispatch => {
return Axios.get("/api/items").then((response) => dispatch(itemsLoaded(response.data)))
}
export const addItem = (name, quantity) => dispatch => {
return Axios.post("/api/items", {name, quantity}).then((response) => dispatch(itemAdded(response.data.id, response.data.name, response.data.quantity)))
}
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