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