Commit e4a1a91b authored by Robert Knight's avatar Robert Knight

Add test for discarding of drafts when annotations are saved

The logic for handling this case in the controller is slightly
indirect. The draft is discarded not when the call to update
the annotation on the server succeeds but whenever the client
is notified that an annotation update has been committed,
signified via its 'updated' property changing.

This happens both for saves triggered locally and also
updates made in other H instances.
parent f8a3823e
...@@ -561,6 +561,20 @@ describe 'annotation', -> ...@@ -561,6 +561,20 @@ describe 'annotation', ->
controller.revert() controller.revert()
assert.calledWith(fakeDrafts.remove, annotation) assert.calledWith(fakeDrafts.remove, annotation)
it "removes the draft when changes are saved", ->
annotation.$update = sandbox.stub().returns(Promise.resolve())
createDirective()
controller.edit()
controller.save()
# the controller currently removes the draft whenever an annotation
# update is committed on the server. This can happen either when saving
# locally or when an update is committed in another instance of H
# which is then pushed to the current instance
annotation.updated = (new Date()).toISOString()
$scope.$digest()
assert.calledWith(fakeDrafts.remove, annotation)
describe "when the focused group changes", -> describe "when the focused group changes", ->
it "updates the current draft", -> it "updates the current draft", ->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment