Commit 483d7233 authored by Martin Fahl's avatar Martin Fahl

removes debounced test and code for increment and decrement persistence

parent ea22495e
import debounced from "../debounced"
describe("debounced", () => {
it("execute function after timeout", async () => {
const delay = 10
const mockFunction = jest.fn()
const debouncedFn = debounced(delay, mockFunction)
debouncedFn()
await new Promise ((resolve) => {
setTimeout(() => {
resolve()
}, delay + 10)
})
expect(mockFunction.mock.calls.length).toBe(1)
})
it("executes only the last function call after timeout", async () => {
const mockFunction = jest.fn()
const delay = 10
const debouncedFn = debounced(delay, mockFunction)
debouncedFn()
debouncedFn()
debouncedFn()
await new Promise ((resolve) => {
setTimeout(() => {
resolve()
}, delay + 10)
})
expect(mockFunction.mock.calls.length).toBe(1)
})
})
\ No newline at end of file
......@@ -13,7 +13,7 @@ export const itemDeleted = id => ({
id
})
export const itemUpdated = (id, name, quantity) => ({
export const updateItem = (id, name, quantity) => ({
type: types.ITEM_UPDATED,
id,
name,
......@@ -35,9 +35,4 @@ export const addItem = (name, quantity) => dispatch => {
export const deleteItem = (id) => dispatch => {
return Axios.delete("/api/items/"+id).then(dispatch(itemDeleted(id)))
}
export const updateItem = (id, name, quantity) => dispatch => {
dispatch(itemUpdated(id, name, quantity))
Axios.put("/api/items/"+id, {id, name, quantity}).catch(dispatch(getAllItems))
}
\ 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