Add test for preventing task with id that already exists
This commit is contained in:
@@ -97,6 +97,27 @@ describe "Todos", ->
|
||||
expect(todo.value).to.equal 0
|
||||
done()
|
||||
|
||||
it "Does not create a todo with an id that already exists", (done) ->
|
||||
original_todo = {
|
||||
type: "todo"
|
||||
text: "original todo"
|
||||
id: "custom-id"
|
||||
}
|
||||
duplicate_id_todo = {
|
||||
type: "todo"
|
||||
text: "not original todo"
|
||||
id: "custom-id"
|
||||
}
|
||||
request.post(baseURL + "/user/tasks").send(
|
||||
original_todo
|
||||
).end (res) ->
|
||||
request.post(baseURL + "/user/tasks").send(
|
||||
duplicate_id_todo
|
||||
).end (res) ->
|
||||
expectCode res, 409
|
||||
expect(res.body.err).to.eql('A task with that ID already exists.')
|
||||
done()
|
||||
|
||||
describe "Updating todos", ->
|
||||
it "Does not update id of todo", (done) ->
|
||||
request.put(baseURL + "/user/tasks/" + todo.id).send(
|
||||
|
||||
Reference in New Issue
Block a user