fix last roles store test
This commit is contained in:
parent
dd21ee2386
commit
d22d5c7c28
|
@ -12,10 +12,7 @@ export function createRolesStore() {
|
||||||
},
|
},
|
||||||
delete: async role => {
|
delete: async role => {
|
||||||
const response = await api.delete(`/api/roles/${role._id}/${role._rev}`)
|
const response = await api.delete(`/api/roles/${role._id}/${role._rev}`)
|
||||||
update(state => {
|
update(state => state.filter(existing => existing._id !== role._id))
|
||||||
state = state.filter(existing => existing._id !== role._id)
|
|
||||||
return state
|
|
||||||
})
|
|
||||||
return response
|
return response
|
||||||
},
|
},
|
||||||
save: async role => {
|
save: async role => {
|
||||||
|
|
|
@ -22,13 +22,14 @@ describe("Roles Store", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("deletes a role", async () => {
|
it("deletes a role", async () => {
|
||||||
api.get.mockReturnValue({ json: () => ROLES})
|
api.get.mockReturnValueOnce({ json: () => ROLES})
|
||||||
await store.fetch()
|
await store.fetch()
|
||||||
|
|
||||||
const {_id, _rev} = ROLES[0]
|
|
||||||
api.delete.mockReturnValue({status: 200, message: `Role deleted.`})
|
api.delete.mockReturnValue({status: 200, message: `Role deleted.`})
|
||||||
await store.delete(`/api/roles/${_id}/${_rev}`)
|
|
||||||
|
const updatedRoles = [...ROLES.slice(1)]
|
||||||
|
await store.delete(ROLES[0])
|
||||||
|
|
||||||
expect(get(store)).toEqual(ROLES)
|
expect(get(store)).toEqual(updatedRoles)
|
||||||
})
|
})
|
||||||
})
|
})
|
Loading…
Reference in New Issue