 describe('DOM', ->
-  testContainer = $('#test-container').get(0)
-  expectContainer = $('#expected-container').get(0)
-
   beforeEach( ->
-    $(testContainer).html('')
+    @container = $('#test-container').html('').get(0)
   )
 
   describe('classes', ->
     afterEach( ->
-      $(testContainer).removeClass()
+      $(@container).removeClass()
     )
 
     it('addClass', ->
-      Quill.DOM.addClass(testContainer, 'custom')
-      expect($(testContainer).hasClass('custom')).to.be(true)
+      Quill.DOM.addClass(@container, 'custom')
+      expect($(@container).hasClass('custom')).to.be(true)
     )
 
     it('getClasses', ->
-      $(testContainer).addClass('custom')
-      $(testContainer).addClass('another')
-      classes = Quill.DOM.getClasses(testContainer)
+      $(@container).addClass('custom')
+      $(@container).addClass('another')
+      classes = Quill.DOM.getClasses(@container)
       expect(_.union(classes, ['custom', 'another']).length).to.equal(2)
     )
 
     it('hasClass', ->
-      $(testContainer).addClass('custom')
-      expect(Quill.DOM.hasClass(testContainer, 'custom')).to.be(true)
+      $(@container).addClass('custom')
+      expect(Quill.DOM.hasClass(@container, 'custom')).to.be(true)
     )
 
     it('removeClass', ->
-      $(testContainer).addClass('custom')
-      Quill.DOM.removeClass(testContainer, 'custom')
-      expect($(testContainer).hasClass('custom')).to.be(false)
+      $(@container).addClass('custom')
+      Quill.DOM.removeClass(@container, 'custom')
+      expect($(@container).hasClass('custom')).to.be(false)
     )
 
     it('toggleClass', ->
-      Quill.DOM.toggleClass(testContainer, 'custom')
-      expect($(testContainer).hasClass('custom')).to.be(true)
-      Quill.DOM.toggleClass(testContainer, 'custom')
-      expect($(testContainer).hasClass('custom')).to.be(false)
+      Quill.DOM.toggleClass(@container, 'custom')
+      expect($(@container).hasClass('custom')).to.be(true)
+      Quill.DOM.toggleClass(@container, 'custom')
+      expect($(@container).hasClass('custom')).to.be(false)
     )
   )
 
   describe('attributes', ->
     beforeEach( ->
-      $(testContainer).html('<div class="custom" style="color: red;"></div>')
-      @node = testContainer.firstChild
+      $(@container).html('<div class="custom" style="color: red;"></div>')
+      @node = @container.firstChild
     )
 
     it('getAttributes', ->


  describe('text', ->
    beforeEach( ->
      $(testContainer).html('0<span>1</span><!-- Comment --><b><i>2</i></b>3<br>')
    )

    it('should retrieve text', ->
      expect(Quill.DOM.getText(testContainer)).to.equal('0123')
    )

    it('should set element text', ->
      Quill.DOM.setText(testContainer, 'test')
      expect($(testContainer).text()).to.equal('test')
    )

    it('should set text node text', ->
      Quill.DOM.setText(testContainer.firstChild, 'A')
      expect($(testContainer).text()).to.equal('A123')
    )

    it('should get all text nodes', ->
      textNodes = Quill.DOM.getTextNodes(testContainer)
      expect(textNodes.length).to.equal(4)
    )
  )

  describe('manipulation', ->
    beforeEach( ->
      $(testContainer).html('<div style="cursor: pointer">One</div><div><span>Two</span><b>Bold</b></div>')
    )

    it('moveChildren', ->
      Quill.DOM.moveChildren(testContainer.firstChild, testContainer.lastChild)
      expect.equalHTML(testContainer, '<div style="cursor: pointer>One<span>Two</span><b>Bold</b></div><div></div>')
    )

    it('removeNode', ->
      Quill.DOM.removeNode(testContainer.lastChild.firstChild)
      expect.equalHTML(testContainer, '<div style="cursor: pointer>One</div><div><b>Bold</b></div>')
    )

    it('switchTag', ->
      Quill.DOM.switchTag(testContainer.firstChild, 'span')
      expect.equalHTML(testContainer, '<span style="cursor: pointer>One</span><div><span>Two</span><b>Bold</b></div>')
    )

    it('unwrap', ->
      Quill.DOM.unwrap(testContainer.lastChild)
      expect.equalHTML(testContainer, '<div style="cursor: pointer>One</div><span>Two</span><b>Bold</b>')
    )

    it('wrap', ->
      wrapper = testContainer.ownerDocument.createElement('div')
      Quill.DOM.wrap(wrapper, testContainer.firstChild)
      expect.equalHTML(testContainer, '<div><div style="cursor: pointer>One</div></div><div><span>Two</span><b>Bold</b></div>')
    )
  )

  describe('select', ->
    beforeEach( ->
      $(testContainer).html('
        <select>
          <option value="one">One</option>
          <option value="two" selected>Two</option>
        </select>
      ')
      @select = testContainer.children[0]
      $(@select).val('one')
    )


      'display': 'inline'

    it('should retrieve styles', ->
      $(@container).html(html)
      result = Quill.DOM.getStyles(@container.firstChild)
      expect(result).to.eql(styles)
    )

    it('should set styles', ->
      $(@container).html('<span>Test</span>')
      Quill.DOM.setStyles(@container.firstChild, styles)
      expect.equalHTML(@container.firstChild.outerHTML, html)
    )
  )

  describe('events', ->
    beforeEach( ->
      $(@container).html('
        <div>
          <button type="button">Button</button>
          <select>
