 
       it('empty document', ->
         @container.innerHTML = '<div></div>'
-        @doc = new Quill.Document(@container.firstChild, { formats: Quill.DEFAULTS.formats })
-        @selection = new Quill.Selection(@doc, @emitter)
-        index = @selection._positionToIndex(@doc.root, 0)
+        quill = new Quill(@container.firstChild)
+        index = quill.editor.selection._positionToIndex(quill.editor.doc.root, 0)
         expect(index).toEqual(0)
       )
     )


      it('empty document', ->
        @container.innerHTML = '<div></div>'
        @doc = new Quill.Document(@container.firstChild, { formats: Quill.DEFAULTS.formats })
        @selection = new Quill.Selection(@doc, @emitter)
        [resultNode, resultIndex] = @selection._normalizePosition(@doc.root, 0)
        expect(resultNode).toEqual(@doc.root)
        expect(resultIndex).toEqual(0)
      )
    )

describe('Selection', ->
  beforeEach( ->
    @container = $('#editor-container').get(0)
    @container.innerHTML = '
      <div>
        <div><span>0123</span></div>
        <div><br></div>
        <div><img></div>
        <div><b><s>89</s></b><i>ab</i></div>
      </div>
    '
    @quill = new Quill(@container.firstChild)   # Need Quill to create iframe for focus logic
    @doc = @quill.editor.doc
    @selection = @quill.editor.selection
  )

  describe('helpers', ->
    tests =
      'text node':
        native: ->
