 StatusBar = require 'status-bar'
 
 describe "StatusBar", ->
-  [rootView, editor, statusBar] = []
+  [rootView, editor, statusBar, buffer] = []
 
   beforeEach ->
     rootView = new RootView(require.resolve('fixtures/sample.js'))

      expect(rootView.panes.find('.pane > .status-bar').length).toBe 2

  describe ".initialize(editor)", ->
    it "displays the editor's buffer path and cursor buffer position", ->
      expect(statusBar.currentPath.text()).toBe 'sample.js'
      expect(statusBar.cursorPosition.text()).toBe '1,1'

    describe "when associated with an unsaved buffer", ->

      rootView.open(require.resolve 'fixtures/sample.txt')
      expect(statusBar.currentPath.text()).toBe 'sample.txt'

  describe "when the associated editor's buffer's content changes", ->
    it "updates the buffer modified indicator", ->
      expect(statusBar.bufferModified.text()).toBe ''
      oldText = buffer.getText()
      editor.insertText("/")
      expect(statusBar.bufferModified.text()).toBe '*'
      editor.backspace()
      buffer.save()
      expect(statusBar.bufferModified.text()).toBe ''

  describe "when the associated editor's cursor position changes", ->
    it "updates the cursor position in the status bar", ->
      editor.setCursorScreenPosition([1, 2])
