Add specs for status bar branch label

This commit is contained in:
Kevin Sawicki
2012-10-25 15:33:45 -07:00
committed by Corey Johnson
parent 8e8ab4ff94
commit 28db13dbc1
2 changed files with 18 additions and 2 deletions

View File

@@ -102,3 +102,19 @@ describe "StatusBar", ->
it "updates the cursor position in the status bar", ->
editor.setCursorScreenPosition([1, 2])
expect(statusBar.cursorPosition.text()).toBe '2,3'
describe "branch label", ->
beforeEach ->
rootView.attachToDom()
it "displays the current branch for files in repositories", ->
path = require.resolve('fixtures/git/master.git/HEAD')
rootView.open(path)
expect(statusBar.branchArea).toBeVisible()
expect(statusBar.branchLabel.text()).toBe 'master'
it "doesn't display the current branch for a file not in a repository", ->
path = require.resolve('fixtures/git/nohead.git/HEAD')
rootView.open(path)
expect(statusBar.branchArea).toBeHidden()
expect(statusBar.branchLabel.text()).toBe ''

View File

@@ -60,10 +60,10 @@ class StatusBar extends View
if path = @editor.getPath()
@head = new Git(path).getShortHead()
else
@head = null
@head = ''
@branchLabel.text(@head)
if @head
@branchLabel.text(@head)
@branchArea.show()
else
@branchArea.hide()