 
 		it 'should delete the entity in the editor controller with the correct type', (done)->
 			@entity.lines = []
-			mock = sinon.mock(@editorController).expects("deleteEntityWithoutLock").withArgs(@project_id, @entity_id, @type, @source, @user_id).callsArg(5)
-			@updateMerger.deleteUpdate @user_id, @project_id, @path, @source, ->
-				mock.verify()
+			@updateMerger.deleteUpdate @user_id, @project_id, @path, @source, =>
+				@editorController.deleteEntityWithoutLock
+					.calledWith(@project_id, @entity_id, @type, @source, @user_id)
+					.should.equal true
 				done()
-
-	

			@splitDocLines = @docLines.split("\n")
			@fs.readFile = sinon.stub().callsArgWith(2, null, @docLines)

		it 'should set the doc text in the editor controller', (done)->
			@editorController.setDoc = ->
			mock = sinon.mock(@editorController).expects("setDoc").withArgs(@project_id, @doc_id, @user_id, @splitDocLines, @source).callsArg(5)

			@update.write(@docLines)
			@update.end()

			@updateMerger.p.processDoc @project_id, @doc_id, @user_id, @update, "path", @source, ->
				mock.verify()
				done()

		it 'should create a new doc when it doesnt exist', (done)->
			folder = {_id:"adslkjioj"}
			docName = "main.tex"
			path = "folder1/folder2/#{docName}"
			@editorController.mkdirpWithoutLock = sinon.stub().withArgs(@project_id).callsArgWith(2, null, [folder], folder)
			@editorController.addDocWithoutLock = ->
			mock = sinon.mock(@editorController).expects("addDocWithoutLock").withArgs(@project_id, folder._id, docName, @splitDocLines, @source, @user_id).callsArg(6)

			@update.write(@docLines)
			@update.end()

			@updateMerger.p.processDoc @project_id, undefined, @user_id, @update, path, @source, ->
				mock.verify()
				done()

	describe 'processFile :', (done)->

				done()

	describe 'delete entity :', (done)->
		beforeEach ->
			@path = "folder/doc1"
			@type = "mock-type"
