Skip to content

Commit

Permalink
Add tests to make sure it's not possible to delete twice
Browse files Browse the repository at this point in the history
  • Loading branch information
alanhoff committed May 1, 2017
1 parent 5da0a25 commit 40c4e09
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/spec/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ lab.experiment('general tests', () => {
expect(model.get('deleted_at')).to.be.a.date()
}))

lab.test('should not be able to delete twice', co.wrap(function * () {
yield Comment.forge({ id: 1 }).destroy()

const error = yield Comment.forge({ id: 1 })
.destroy({ require: true })
.catch((err) => err)

expect(error).to.be.instanceOf(Comment.NoRowsDeletedError)
}))

lab.test('should work with user-provided time as Date', co.wrap(function * () {
const now = new Date()
let model = yield Comment.forge({ id: 1 }).destroy({ date: now })
Expand Down

0 comments on commit 40c4e09

Please sign in to comment.