Skip to content

Commit

Permalink
Query user's db and not post's (kentcdodds#65)
Browse files Browse the repository at this point in the history
* Query user's db and not post's

* Update users.js
  • Loading branch information
sasharevzin authored and Kent C. Dodds committed Mar 30, 2018
1 parent 8318a19 commit 680c9ae
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server/src/controllers/__tests__/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ test('deleteUser deletes a user', async () => {
const firstArg = firstCall[0]
const {user} = firstArg
expect(user).toEqual(safeUser(testUser))
const userFromDb = await db.getPost(user.id)
const userFromDb = await db.getUser(user.id)
expect(userFromDb).not.toBeDefined()
})

Expand All @@ -115,7 +115,7 @@ test('deleteUser will 404 if made to a non-existing user', async () => {
})

test('deleteUser will 403 if not made by the author', async () => {
const testUser = await db.insertPost(generate.userData())
const testUser = await db.insertUser(generate.userData())
const {req, res} = setup()
req.params = {id: testUser.id}

Expand All @@ -125,6 +125,6 @@ test('deleteUser will 403 if not made by the author', async () => {
expect(res.status).toHaveBeenCalledTimes(1)
expect(res.status).toHaveBeenCalledWith(403)
expect(res.send).toHaveBeenCalledTimes(1)
const userFromDb = await db.getPost(testUser.id)
const userFromDb = await db.getUser(testUser.id)
expect(userFromDb).toEqual(testUser)
})

0 comments on commit 680c9ae

Please sign in to comment.