 
         $compile('<div cm-editor sharejs-doc="sharejsDoc"></div>')($rootScope)
         $rootScope.$digest()
+        $rootScope.$digest()
 
+        expect(detachFromCM).to.have.been.called
         expect(getSnapshot).to.have.been.called
-        expect(setValue).to.have.been.called
-        expect(detachFromCM).to.have.been.called
+        expect(@richTextOpenDoc).to.have.been.called
         expect(attachToCM).to.have.been.called
 
     it 'detaches from CM when destroyed', () ->


    beforeEach () ->
      @richTextInit = sinon.stub()
      window.Frontend = {
        richText: {
          init: @richTextInit
        }
      }



    it 'attaches to CM', () ->
      inject ($compile, $rootScope) ->
        getSnapshot = sinon.stub()
        detachFromCM = sinon.stub()
        attachToCM = sinon.stub()
