Help with CRUD tests #4045
Answered
by
McSneaky
letiesperon
asked this question in
Help
-
What's the right way to assert that the destroy action actually deleted the record? This is what I have but it's incomplete test('logged in with "{rol}" role')
.with(async () => {
return await Promise.all([
UsuarioFactory.apply('writer').create(),
UsuarioFactory.apply('admin').create(),
])
})
.run(async ({ assert, client }, user) => {
const response = await client.delete(`/docentes/${docente.id}`).loginAs(user)
response.assertStatus(204)
// OPTION 1: Use refresh?
try {
await docente.refresh()
} catch {
// correct??
}
// OPTION 2:
const reloadedDocente = await Docente.findBy('cedula', '1249933')
assert.isNull(reloadedDocente)
}) |
Beta Was this translation helpful? Give feedback.
Answered by
McSneaky
Jan 17, 2023
Replies: 1 comment
-
I'd go with option 2 🙂 Might just replace |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
letiesperon
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd go with option 2 🙂 Might just replace
1249933
withdocente.id