         assert.ok isToolbarButtonDisabled(attribute: "bullet")
         done()
 
-  test "breaking out of heading in list", (done) ->
+  test "breaking out of heading in list", (expectDocument) ->
     clickToolbarButton attribute: "bullet", ->
       clickToolbarButton attribute: "heading1", ->
         assert.ok isToolbarButtonActive(attribute: "heading1")

            assert.ok isToolbarButtonActive(attribute: "bullet")
            document = getDocument()
            assert.equal document.getBlockCount(), 2

            block = document.getBlockAtIndex(0)
            assert.deepEqual block.getAttributes(), ["bulletList", "bullet", "heading1"]
            assert.equal block.toString(), "abc\n"

            block = document.getBlockAtIndex(1)
            assert.deepEqual block.getAttributes(), ["bulletList", "bullet"]

            done()

  test "breaking out of middle of heading block", (done) ->
    clickToolbarButton attribute: "heading1", ->
      typeCharacters "abc", ->
        moveCursor direction: "left", times: 1, ->
          typeCharacters "\n", ->
            assert.ok isToolbarButtonActive(attribute: "heading1")

            document = getDocument()
            assert.equal document.getBlockCount(), 1

            block = document.getBlockAtIndex(0)
            assert.deepEqual block.getAttributes(), ["heading1"]
            assert.equal block.toString(), "ab\nc\n"

            done()

  test "inserting newline before heading", (done) ->

    document = new Trix.Document [
        new Trix.Block(Trix.Text.textForStringWithAttributes("\n"), [])
        new Trix.Block(Trix.Text.textForStringWithAttributes("abc"), ["heading1"])

      ]

    replaceDocument(document)
    getEditorController().setLocationRange([{index: 0, offset: 0}, {index: 0, offset: 0}])

    typeCharacters "\n", ->
      document = getDocument()


      done()

  test "inserting newline after single character header", (expectDocument) ->
    clickToolbarButton attribute: "heading1", ->
      typeCharacters "a", ->
        typeCharacters "\n", ->
          document = getDocument()
          assert.equal document.getBlockCount(), 2
          assert.blockAttributes([0, 1], ["heading1"])
          expectDocument("a\n\n")
