mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-11 11:15:24 +03:00
Manual decaf status-bar
specs
This commit is contained in:
parent
12643554cc
commit
0d5864f986
@ -1,659 +0,0 @@
|
||||
fs = require 'fs-plus'
|
||||
path = require 'path'
|
||||
os = require 'os'
|
||||
process = require 'process'
|
||||
|
||||
describe "Built-in Status Bar Tiles", ->
|
||||
[statusBar, workspaceElement, dummyView] = []
|
||||
|
||||
beforeEach ->
|
||||
workspaceElement = atom.views.getView(atom.workspace)
|
||||
dummyView = document.createElement("div")
|
||||
statusBar = null
|
||||
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage('status-bar')
|
||||
|
||||
runs ->
|
||||
statusBar = workspaceElement.querySelector("status-bar")
|
||||
|
||||
describe "the file info, cursor and selection tiles", ->
|
||||
[editor, buffer, fileInfo, cursorPosition, selectionCount] = []
|
||||
|
||||
beforeEach ->
|
||||
waitsForPromise ->
|
||||
atom.workspace.open('sample.js')
|
||||
|
||||
runs ->
|
||||
[launchMode, fileInfo, cursorPosition, selectionCount] =
|
||||
statusBar.getLeftTiles().map (tile) -> tile.getItem()
|
||||
editor = atom.workspace.getActiveTextEditor()
|
||||
buffer = editor.getBuffer()
|
||||
|
||||
describe "when associated with an unsaved buffer", ->
|
||||
it "displays 'untitled' instead of the buffer's path, but still displays the buffer position", ->
|
||||
waitsForPromise ->
|
||||
atom.workspace.open()
|
||||
|
||||
runs ->
|
||||
atom.views.performDocumentUpdate()
|
||||
expect(fileInfo.currentPath.textContent).toBe 'untitled'
|
||||
expect(cursorPosition.textContent).toBe '1:1'
|
||||
expect(selectionCount).toBeHidden()
|
||||
|
||||
describe "when the associated editor's path changes", ->
|
||||
it "updates the path in the status bar", ->
|
||||
waitsForPromise ->
|
||||
atom.workspace.open('sample.txt')
|
||||
|
||||
runs ->
|
||||
expect(fileInfo.currentPath.textContent).toBe 'sample.txt'
|
||||
|
||||
describe "when associated with remote file path", ->
|
||||
beforeEach ->
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
dummyView.getPath = -> 'remote://server:123/folder/remote_file.txt'
|
||||
atom.workspace.getActivePane().activateItem(dummyView)
|
||||
|
||||
it "updates the path in the status bar", ->
|
||||
# The remote path isn't relativized in the test because no remote directory provider is registered.
|
||||
expect(fileInfo.currentPath.textContent).toBe 'remote://server:123/folder/remote_file.txt'
|
||||
expect(fileInfo.currentPath).toBeVisible()
|
||||
|
||||
it "when the path is clicked", ->
|
||||
fileInfo.currentPath.click()
|
||||
expect(atom.clipboard.read()).toBe '/folder/remote_file.txt'
|
||||
|
||||
it "calls relativize with the remote URL on shift-click", ->
|
||||
spy = spyOn(atom.project, 'relativize').andReturn 'remote_file.txt'
|
||||
event = new MouseEvent('click', shiftKey: true)
|
||||
fileInfo.dispatchEvent(event)
|
||||
expect(atom.clipboard.read()).toBe 'remote_file.txt'
|
||||
expect(spy).toHaveBeenCalledWith 'remote://server:123/folder/remote_file.txt'
|
||||
|
||||
describe "when file info tile is clicked", ->
|
||||
it "copies the absolute path into the clipboard if available", ->
|
||||
waitsForPromise ->
|
||||
atom.workspace.open('sample.txt')
|
||||
|
||||
runs ->
|
||||
fileInfo.click()
|
||||
expect(atom.clipboard.read()).toBe fileInfo.getActiveItem().getPath()
|
||||
|
||||
describe "when the file info tile is shift-clicked", ->
|
||||
it "copies the relative path into the clipboard if available", ->
|
||||
waitsForPromise ->
|
||||
atom.workspace.open('sample.txt')
|
||||
|
||||
runs ->
|
||||
event = new MouseEvent('click', shiftKey: true)
|
||||
fileInfo.dispatchEvent(event)
|
||||
expect(atom.clipboard.read()).toBe 'sample.txt'
|
||||
|
||||
describe "when path of an unsaved buffer is clicked", ->
|
||||
it "copies the 'untitled' into clipboard", ->
|
||||
waitsForPromise ->
|
||||
atom.workspace.open()
|
||||
|
||||
runs ->
|
||||
fileInfo.currentPath.click()
|
||||
expect(atom.clipboard.read()).toBe 'untitled'
|
||||
|
||||
describe "when buffer's path is not clicked", ->
|
||||
it "doesn't display a path tooltip", ->
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
waitsForPromise ->
|
||||
atom.workspace.open()
|
||||
|
||||
runs ->
|
||||
expect(document.querySelector('.tooltip')).not.toExist()
|
||||
|
||||
describe "when buffer's path is clicked", ->
|
||||
it "displays path tooltip and the tooltip disappears after ~2 seconds", ->
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
waitsForPromise ->
|
||||
atom.workspace.open()
|
||||
|
||||
runs ->
|
||||
fileInfo.currentPath.click()
|
||||
expect(document.querySelector('.tooltip')).toBeVisible()
|
||||
# extra leeway so test won't fail because tooltip disappeared few milliseconds too late
|
||||
advanceClock(2100)
|
||||
expect(document.querySelector('.tooltip')).not.toExist()
|
||||
|
||||
describe "when saved buffer's path is clicked", ->
|
||||
it "displays a tooltip containing text 'Copied:' and an absolute native path", ->
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
waitsForPromise ->
|
||||
atom.workspace.open('sample.txt')
|
||||
|
||||
runs ->
|
||||
fileInfo.currentPath.click()
|
||||
expect(document.querySelector('.tooltip')).toHaveText "Copied: #{fileInfo.getActiveItem().getPath()}"
|
||||
|
||||
it "displays a tooltip containing text 'Copied:' for an absolute Unix path", ->
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
dummyView.getPath = -> '/user/path/for/my/file.txt'
|
||||
atom.workspace.getActivePane().activateItem(dummyView)
|
||||
|
||||
runs ->
|
||||
fileInfo.currentPath.click()
|
||||
expect(document.querySelector('.tooltip')).toHaveText "Copied: #{dummyView.getPath()}"
|
||||
|
||||
it "displays a tooltip containing text 'Copied:' for an absolute Windows path", ->
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
dummyView.getPath = -> 'c:\\user\\path\\for\\my\\file.txt'
|
||||
atom.workspace.getActivePane().activateItem(dummyView)
|
||||
|
||||
runs ->
|
||||
fileInfo.currentPath.click()
|
||||
expect(document.querySelector('.tooltip')).toHaveText "Copied: #{dummyView.getPath()}"
|
||||
|
||||
describe "when unsaved buffer's path is clicked", ->
|
||||
it "displays a tooltip containing text 'Copied: untitled", ->
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
waitsForPromise ->
|
||||
atom.workspace.open()
|
||||
|
||||
runs ->
|
||||
fileInfo.currentPath.click()
|
||||
expect(document.querySelector('.tooltip')).toHaveText "Copied: untitled"
|
||||
|
||||
describe "when the associated editor's buffer's content changes", ->
|
||||
it "enables the buffer modified indicator", ->
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(false)
|
||||
editor.insertText("\n")
|
||||
advanceClock(buffer.stoppedChangingDelay)
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(true)
|
||||
editor.backspace()
|
||||
|
||||
describe "when the buffer content has changed from the content on disk", ->
|
||||
it "disables the buffer modified indicator on save", ->
|
||||
filePath = path.join(os.tmpdir(), "atom-whitespace.txt")
|
||||
fs.writeFileSync(filePath, "")
|
||||
|
||||
waitsForPromise ->
|
||||
atom.workspace.open(filePath)
|
||||
|
||||
runs ->
|
||||
editor = atom.workspace.getActiveTextEditor()
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(false)
|
||||
editor.insertText("\n")
|
||||
advanceClock(buffer.stoppedChangingDelay)
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(true)
|
||||
|
||||
waitsForPromise ->
|
||||
# TODO - remove this Promise.resolve once atom/atom#14435 lands.
|
||||
Promise.resolve(editor.getBuffer().save())
|
||||
|
||||
runs ->
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(false)
|
||||
|
||||
it "disables the buffer modified indicator if the content matches again", ->
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(false)
|
||||
editor.insertText("\n")
|
||||
advanceClock(buffer.stoppedChangingDelay)
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(true)
|
||||
editor.backspace()
|
||||
advanceClock(buffer.stoppedChangingDelay)
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(false)
|
||||
|
||||
it "disables the buffer modified indicator when the change is undone", ->
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(false)
|
||||
editor.insertText("\n")
|
||||
advanceClock(buffer.stoppedChangingDelay)
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(true)
|
||||
editor.undo()
|
||||
advanceClock(buffer.stoppedChangingDelay)
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(false)
|
||||
|
||||
describe "when the buffer changes", ->
|
||||
it "updates the buffer modified indicator for the new buffer", ->
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(false)
|
||||
|
||||
waitsForPromise ->
|
||||
atom.workspace.open('sample.txt')
|
||||
|
||||
runs ->
|
||||
editor = atom.workspace.getActiveTextEditor()
|
||||
editor.insertText("\n")
|
||||
advanceClock(buffer.stoppedChangingDelay)
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(true)
|
||||
|
||||
it "doesn't update the buffer modified indicator for the old buffer", ->
|
||||
oldBuffer = editor.getBuffer()
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(false)
|
||||
|
||||
waitsForPromise ->
|
||||
atom.workspace.open('sample.txt')
|
||||
|
||||
runs ->
|
||||
oldBuffer.setText("new text")
|
||||
advanceClock(buffer.stoppedChangingDelay)
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(false)
|
||||
|
||||
describe "when the associated editor's cursor position changes", ->
|
||||
it "updates the cursor position in the status bar", ->
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
editor.setCursorScreenPosition([1, 2])
|
||||
atom.views.performDocumentUpdate()
|
||||
expect(cursorPosition.textContent).toBe '2:3'
|
||||
|
||||
it "does not throw an exception if the cursor is moved as the result of the active pane item changing to a non-editor (regression)", ->
|
||||
waitsForPromise ->
|
||||
Promise.resolve(atom.packages.deactivatePackage('status-bar')) # Wrapped so works with Promise & non-Promise deactivate
|
||||
runs ->
|
||||
atom.workspace.onDidChangeActivePaneItem(-> editor.setCursorScreenPosition([1, 2]))
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage('status-bar')
|
||||
runs ->
|
||||
statusBar = workspaceElement.querySelector("status-bar")
|
||||
cursorPosition = statusBar.getLeftTiles()[2].getItem()
|
||||
|
||||
atom.workspace.getActivePane().activateItem(document.createElement('div'))
|
||||
expect(editor.getCursorScreenPosition()).toEqual([1, 2])
|
||||
atom.views.performDocumentUpdate()
|
||||
expect(cursorPosition).toBeHidden()
|
||||
|
||||
describe "when the associated editor's selection changes", ->
|
||||
it "updates the selection count in the status bar", ->
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
|
||||
editor.setSelectedBufferRange([[0, 0], [0, 0]])
|
||||
atom.views.performDocumentUpdate()
|
||||
expect(selectionCount.textContent).toBe ''
|
||||
|
||||
editor.setSelectedBufferRange([[0, 0], [0, 2]])
|
||||
atom.views.performDocumentUpdate()
|
||||
expect(selectionCount.textContent).toBe '(1, 2)'
|
||||
|
||||
editor.setSelectedBufferRange([[0, 0], [1, 30]])
|
||||
atom.views.performDocumentUpdate()
|
||||
expect(selectionCount.textContent).toBe "(2, 60)"
|
||||
|
||||
it "does not throw an exception if the cursor is moved as the result of the active pane item changing to a non-editor (regression)", ->
|
||||
waitsForPromise ->
|
||||
Promise.resolve(atom.packages.deactivatePackage('status-bar')) # Wrapped so works with Promise & non-Promise deactivate
|
||||
runs ->
|
||||
atom.workspace.onDidChangeActivePaneItem(-> editor.setSelectedBufferRange([[1, 2], [1, 3]]))
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage('status-bar')
|
||||
runs ->
|
||||
statusBar = workspaceElement.querySelector("status-bar")
|
||||
selectionCount = statusBar.getLeftTiles()[3].getItem()
|
||||
|
||||
atom.workspace.getActivePane().activateItem(document.createElement('div'))
|
||||
expect(editor.getSelectedBufferRange()).toEqual([[1, 2], [1, 3]])
|
||||
atom.views.performDocumentUpdate()
|
||||
expect(selectionCount).toBeHidden()
|
||||
|
||||
describe "when the active pane item does not implement getCursorBufferPosition()", ->
|
||||
it "hides the cursor position view", ->
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
atom.workspace.getActivePane().activateItem(dummyView)
|
||||
atom.views.performDocumentUpdate()
|
||||
expect(cursorPosition).toBeHidden()
|
||||
|
||||
describe "when the active pane item implements getTitle() but not getPath()", ->
|
||||
it "displays the title", ->
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
dummyView.getTitle = -> 'View Title'
|
||||
atom.workspace.getActivePane().activateItem(dummyView)
|
||||
expect(fileInfo.currentPath.textContent).toBe 'View Title'
|
||||
expect(fileInfo.currentPath).toBeVisible()
|
||||
|
||||
describe "when the active pane item neither getTitle() nor getPath()", ->
|
||||
it "hides the path view", ->
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
atom.workspace.getActivePane().activateItem(dummyView)
|
||||
expect(fileInfo.currentPath).toBeHidden()
|
||||
|
||||
describe "when the active pane item's title changes", ->
|
||||
it "updates the path view with the new title", ->
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
callbacks = []
|
||||
dummyView.onDidChangeTitle = (fn) ->
|
||||
callbacks.push(fn)
|
||||
{
|
||||
dispose: ->
|
||||
}
|
||||
dummyView.getTitle = -> 'View Title'
|
||||
atom.workspace.getActivePane().activateItem(dummyView)
|
||||
expect(fileInfo.currentPath.textContent).toBe 'View Title'
|
||||
dummyView.getTitle = -> 'New Title'
|
||||
callback() for callback in callbacks
|
||||
expect(fileInfo.currentPath.textContent).toBe 'New Title'
|
||||
|
||||
describe 'the cursor position tile', ->
|
||||
beforeEach ->
|
||||
atom.config.set('status-bar.cursorPositionFormat', 'foo %L bar %C')
|
||||
|
||||
it 'respects a format string', ->
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
editor.setCursorScreenPosition([1, 2])
|
||||
atom.views.performDocumentUpdate()
|
||||
expect(cursorPosition.textContent).toBe 'foo 2 bar 3'
|
||||
|
||||
it 'updates when the configuration changes', ->
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
editor.setCursorScreenPosition([1, 2])
|
||||
atom.views.performDocumentUpdate()
|
||||
expect(cursorPosition.textContent).toBe 'foo 2 bar 3'
|
||||
|
||||
atom.config.set('status-bar.cursorPositionFormat', 'baz %C quux %L')
|
||||
atom.views.performDocumentUpdate()
|
||||
expect(cursorPosition.textContent).toBe 'baz 3 quux 2'
|
||||
|
||||
describe "when clicked", ->
|
||||
it "triggers the go-to-line toggle event", ->
|
||||
eventHandler = jasmine.createSpy('eventHandler')
|
||||
atom.commands.add('atom-text-editor', 'go-to-line:toggle', eventHandler)
|
||||
cursorPosition.click()
|
||||
expect(eventHandler).toHaveBeenCalled()
|
||||
|
||||
describe 'the selection count tile', ->
|
||||
beforeEach ->
|
||||
atom.config.set('status-bar.selectionCountFormat', '%L foo %C bar selected')
|
||||
|
||||
it 'respects a format string', ->
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
editor.setSelectedBufferRange([[0, 0], [1, 30]])
|
||||
atom.views.performDocumentUpdate()
|
||||
expect(selectionCount.textContent).toBe "2 foo 60 bar selected"
|
||||
|
||||
it 'updates when the configuration changes', ->
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
editor.setSelectedBufferRange([[0, 0], [1, 30]])
|
||||
atom.views.performDocumentUpdate()
|
||||
expect(selectionCount.textContent).toBe "2 foo 60 bar selected"
|
||||
|
||||
atom.config.set('status-bar.selectionCountFormat', 'Selection: baz %C quux %L')
|
||||
atom.views.performDocumentUpdate()
|
||||
expect(selectionCount.textContent).toBe "Selection: baz 60 quux 2"
|
||||
|
||||
it 'does not include the next line if the last selected character is a LF', ->
|
||||
lineEndingRegExp = /\r\n|\n|\r/g
|
||||
buffer = editor.getBuffer()
|
||||
buffer.setText(buffer.getText().replace(lineEndingRegExp, '\n'))
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
editor.setSelectedBufferRange([[0, 0], [1, 0]])
|
||||
atom.views.performDocumentUpdate()
|
||||
expect(selectionCount.textContent).toBe "1 foo 30 bar selected"
|
||||
|
||||
it 'does not include the next line if the last selected character is CRLF', ->
|
||||
lineEndingRegExp = /\r\n|\n|\r/g
|
||||
buffer = editor.getBuffer()
|
||||
buffer.setText(buffer.getText().replace(lineEndingRegExp, '\r\n'))
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
editor.setSelectedBufferRange([[0, 0], [1, 0]])
|
||||
atom.views.performDocumentUpdate()
|
||||
expect(selectionCount.textContent).toBe "1 foo 31 bar selected"
|
||||
|
||||
describe "the git tile", ->
|
||||
gitView = null
|
||||
|
||||
hover = (element, fn) ->
|
||||
# FIXME: Only use hoverDefaults once Atom 1.13 is on stable
|
||||
hoverDelay = atom.tooltips.defaults.delay?.show ? atom.tooltips.hoverDefaults.delay.show
|
||||
element.dispatchEvent(new CustomEvent('mouseenter', bubbles: false))
|
||||
element.dispatchEvent(new CustomEvent('mouseover', bubbles: true))
|
||||
advanceClock(hoverDelay)
|
||||
fn()
|
||||
element.dispatchEvent(new CustomEvent('mouseleave', bubbles: false))
|
||||
element.dispatchEvent(new CustomEvent('mouseout', bubbles: true))
|
||||
advanceClock(hoverDelay)
|
||||
|
||||
setupWorkingDir = (name) ->
|
||||
dir = atom.project.getDirectories()[0]
|
||||
target = "#{os.tmpdir()}/#{name}"
|
||||
targetGit = target + '/.git'
|
||||
fs.copySync(dir.resolve('git/working-dir'), path.resolve(target))
|
||||
fs.removeSync(path.resolve(targetGit))
|
||||
fs.copySync(dir.resolve("git/#{name}.git"), path.resolve(targetGit))
|
||||
target
|
||||
|
||||
beforeEach ->
|
||||
[gitView] = statusBar.getRightTiles().map (tile) -> tile.getItem()
|
||||
|
||||
describe "the git ahead/behind count labels", ->
|
||||
beforeEach ->
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
|
||||
it "shows the number of commits that can be pushed/pulled", ->
|
||||
workingDir = setupWorkingDir('ahead-behind-repo')
|
||||
atom.project.setPaths([workingDir])
|
||||
filePath = atom.project.getDirectories()[0].resolve('a.txt')
|
||||
repo = atom.project.getRepositories()[0]
|
||||
|
||||
waitsForPromise ->
|
||||
atom.workspace.open(filePath)
|
||||
.then -> repo.refreshStatus()
|
||||
|
||||
runs ->
|
||||
behindElement = document.body.querySelector(".commits-behind-label")
|
||||
aheadElement = document.body.querySelector(".commits-ahead-label")
|
||||
expect(aheadElement).toBeVisible()
|
||||
expect(behindElement).toBeVisible()
|
||||
expect(aheadElement.textContent).toContain '1'
|
||||
|
||||
it "stays hidden when no commits can be pushed/pulled", ->
|
||||
workingDir = setupWorkingDir('no-ahead-behind-repo')
|
||||
atom.project.setPaths([workingDir])
|
||||
filePath = atom.project.getDirectories()[0].resolve('a.txt')
|
||||
repo = atom.project.getRepositories()[0]
|
||||
|
||||
waitsForPromise ->
|
||||
atom.workspace.open(filePath)
|
||||
.then -> repo.refreshStatus()
|
||||
|
||||
runs ->
|
||||
behindElement = document.body.querySelector(".commits-behind-label")
|
||||
aheadElement = document.body.querySelector(".commits-ahead-label")
|
||||
expect(aheadElement).not.toBeVisible()
|
||||
expect(behindElement).not.toBeVisible()
|
||||
|
||||
describe "the git branch label", ->
|
||||
projectPath = null
|
||||
beforeEach ->
|
||||
projectPath = atom.project.getDirectories()[0].resolve('git/working-dir')
|
||||
fs.moveSync(path.join(projectPath, 'git.git'), path.join(projectPath, '.git'))
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
|
||||
afterEach ->
|
||||
fs.moveSync(path.join(projectPath, '.git'), path.join(projectPath, 'git.git'))
|
||||
|
||||
it "displays the current branch for files in repositories", ->
|
||||
atom.project.setPaths([projectPath])
|
||||
|
||||
waitsForPromise ->
|
||||
atom.workspace.open('a.txt')
|
||||
|
||||
runs ->
|
||||
currentBranch = atom.project.getRepositories()[0].getShortHead()
|
||||
expect(gitView.branchArea).toBeVisible()
|
||||
expect(gitView.branchLabel.textContent).toBe currentBranch
|
||||
|
||||
atom.workspace.getActivePane().destroyItems()
|
||||
expect(gitView.branchArea).toBeVisible()
|
||||
expect(gitView.branchLabel.textContent).toBe currentBranch
|
||||
|
||||
atom.workspace.getActivePane().activateItem(dummyView)
|
||||
|
||||
runs -> expect(gitView.branchArea).not.toBeVisible()
|
||||
|
||||
it "displays the current branch tooltip", ->
|
||||
atom.project.setPaths([projectPath])
|
||||
|
||||
waitsForPromise ->
|
||||
atom.workspace.open('a.txt')
|
||||
|
||||
runs ->
|
||||
currentBranch = atom.project.getRepositories()[0].getShortHead()
|
||||
hover gitView.branchArea, ->
|
||||
expect(document.body.querySelector(".tooltip").innerText)
|
||||
.toBe("On branch #{currentBranch}")
|
||||
|
||||
it "doesn't display the current branch for a file not in a repository", ->
|
||||
atom.project.setPaths([os.tmpdir()])
|
||||
|
||||
waitsForPromise ->
|
||||
atom.workspace.open(path.join(os.tmpdir(), 'temp.txt'))
|
||||
|
||||
runs ->
|
||||
expect(gitView.branchArea).toBeHidden()
|
||||
|
||||
it "doesn't display the current branch for a file outside the current project", ->
|
||||
waitsForPromise ->
|
||||
atom.workspace.open(path.join(os.tmpdir(), 'atom-specs', 'not-in-project.txt'))
|
||||
|
||||
runs ->
|
||||
expect(gitView.branchArea).toBeHidden()
|
||||
|
||||
describe "the git status label", ->
|
||||
[repo, filePath, originalPathText, newPath, ignorePath, ignoredPath, projectPath] = []
|
||||
|
||||
beforeEach ->
|
||||
projectPath = atom.project.getDirectories()[0].resolve('git/working-dir')
|
||||
fs.moveSync(path.join(projectPath, 'git.git'), path.join(projectPath, '.git'))
|
||||
atom.project.setPaths([projectPath])
|
||||
filePath = atom.project.getDirectories()[0].resolve('a.txt')
|
||||
newPath = atom.project.getDirectories()[0].resolve('new.txt')
|
||||
fs.writeFileSync(newPath, "I'm new here")
|
||||
ignorePath = path.join(projectPath, '.gitignore')
|
||||
fs.writeFileSync(ignorePath, 'ignored.txt')
|
||||
ignoredPath = path.join(projectPath, 'ignored.txt')
|
||||
fs.writeFileSync(ignoredPath, '')
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
|
||||
repo = atom.project.getRepositories()[0]
|
||||
originalPathText = fs.readFileSync(filePath, 'utf8')
|
||||
waitsForPromise -> repo.refreshStatus()
|
||||
|
||||
afterEach ->
|
||||
fs.writeFileSync(filePath, originalPathText)
|
||||
fs.removeSync(newPath)
|
||||
fs.removeSync(ignorePath)
|
||||
fs.removeSync(ignoredPath)
|
||||
fs.moveSync(path.join(projectPath, '.git'), path.join(projectPath, 'git.git'))
|
||||
|
||||
it "displays the modified icon for a changed file", ->
|
||||
waitsForPromise ->
|
||||
atom.workspace.open(filePath)
|
||||
.then ->
|
||||
fs.writeFileSync(filePath, "i've changed for the worse")
|
||||
repo.refreshStatus()
|
||||
runs ->
|
||||
expect(gitView.gitStatusIcon).toHaveClass('icon-diff-modified')
|
||||
|
||||
it "displays the 1 line added and not committed tooltip", ->
|
||||
waitsForPromise ->
|
||||
atom.workspace.open(filePath)
|
||||
.then ->
|
||||
fs.writeFileSync(filePath, "i've changed for the worse")
|
||||
repo.refreshStatus()
|
||||
|
||||
runs ->
|
||||
hover gitView.gitStatusIcon, ->
|
||||
expect(document.body.querySelector(".tooltip").innerText)
|
||||
.toBe("1 line added to this file not yet committed")
|
||||
|
||||
it "displays the x lines added and not committed tooltip", ->
|
||||
waitsForPromise ->
|
||||
atom.workspace.open(filePath)
|
||||
.then ->
|
||||
fs.writeFileSync(filePath, "i've changed#{os.EOL}for the worse")
|
||||
repo.refreshStatus()
|
||||
|
||||
runs ->
|
||||
hover gitView.gitStatusIcon, ->
|
||||
expect(document.body.querySelector(".tooltip").innerText)
|
||||
.toBe("2 lines added to this file not yet committed")
|
||||
|
||||
it "doesn't display the modified icon for an unchanged file", ->
|
||||
waitsForPromise ->
|
||||
atom.workspace.open(filePath)
|
||||
.then -> repo.refreshStatus()
|
||||
|
||||
runs ->
|
||||
expect(gitView.gitStatusIcon).toHaveText('')
|
||||
|
||||
it "displays the new icon for a new file", ->
|
||||
waitsForPromise ->
|
||||
atom.workspace.open(newPath)
|
||||
.then -> repo.refreshStatus()
|
||||
|
||||
runs ->
|
||||
expect(gitView.gitStatusIcon).toHaveClass('icon-diff-added')
|
||||
hover gitView.gitStatusIcon, ->
|
||||
expect(document.body.querySelector(".tooltip").innerText)
|
||||
.toBe("1 line in this new file not yet committed")
|
||||
|
||||
it "displays the 1 line added and not committed to new file tooltip", ->
|
||||
waitsForPromise ->
|
||||
atom.workspace.open(newPath)
|
||||
.then -> repo.refreshStatus()
|
||||
|
||||
runs ->
|
||||
hover gitView.gitStatusIcon, ->
|
||||
expect(document.body.querySelector(".tooltip").innerText)
|
||||
.toBe("1 line in this new file not yet committed")
|
||||
|
||||
it "displays the x lines added and not committed to new file tooltip", ->
|
||||
fs.writeFileSync(newPath, "I'm new#{os.EOL}here")
|
||||
waitsForPromise ->
|
||||
atom.workspace.open(newPath)
|
||||
.then -> repo.refreshStatus()
|
||||
|
||||
runs ->
|
||||
hover gitView.gitStatusIcon, ->
|
||||
expect(document.body.querySelector(".tooltip").innerText)
|
||||
.toBe("2 lines in this new file not yet committed")
|
||||
|
||||
it "displays the ignored icon for an ignored file", ->
|
||||
waitsForPromise ->
|
||||
atom.workspace.open(ignoredPath)
|
||||
|
||||
runs ->
|
||||
expect(gitView.gitStatusIcon).toHaveClass('icon-diff-ignored')
|
||||
hover gitView.gitStatusIcon, ->
|
||||
expect(document.body.querySelector(".tooltip").innerText)
|
||||
.toBe("File is ignored by git")
|
||||
|
||||
it "updates when a status-changed event occurs", ->
|
||||
waitsForPromise ->
|
||||
atom.workspace.open(filePath)
|
||||
.then ->
|
||||
fs.writeFileSync(filePath, "i've changed for the worse")
|
||||
repo.refreshStatus()
|
||||
runs ->
|
||||
expect(gitView.gitStatusIcon).toHaveClass('icon-diff-modified')
|
||||
|
||||
waitsForPromise ->
|
||||
fs.writeFileSync(filePath, originalPathText)
|
||||
repo.refreshStatus()
|
||||
runs ->
|
||||
expect(gitView.gitStatusIcon).not.toHaveClass('icon-diff-modified')
|
||||
|
||||
it "displays the diff stat for modified files", ->
|
||||
waitsForPromise ->
|
||||
atom.workspace.open(filePath)
|
||||
.then ->
|
||||
fs.writeFileSync(filePath, "i've changed for the worse")
|
||||
repo.refreshStatus()
|
||||
runs ->
|
||||
expect(gitView.gitStatusIcon).toHaveText('+1')
|
||||
|
||||
it "displays the diff stat for new files", ->
|
||||
waitsForPromise ->
|
||||
atom.workspace.open(newPath)
|
||||
.then -> repo.refreshStatus()
|
||||
|
||||
runs ->
|
||||
expect(gitView.gitStatusIcon).toHaveText('+1')
|
||||
|
||||
it "does not display for files not in the current project", ->
|
||||
waitsForPromise ->
|
||||
atom.workspace.open('/tmp/atom-specs/not-in-project.txt')
|
||||
|
||||
runs ->
|
||||
expect(gitView.gitStatusIcon).toBeHidden()
|
@ -1,10 +1,4 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS101: Remove unnecessary use of Array.from
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
|
||||
const fs = require('fs-plus');
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
@ -20,7 +14,7 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
|
||||
waitsForPromise(() => atom.packages.activatePackage('status-bar'));
|
||||
|
||||
return runs(() => statusBar = workspaceElement.querySelector("status-bar"));
|
||||
runs(() => statusBar = workspaceElement.querySelector("status-bar"));
|
||||
});
|
||||
|
||||
describe("the file info, cursor and selection tiles", function() {
|
||||
@ -29,7 +23,7 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
beforeEach(function() {
|
||||
waitsForPromise(() => atom.workspace.open('sample.js'));
|
||||
|
||||
return runs(function() {
|
||||
runs(function() {
|
||||
let launchMode;
|
||||
[launchMode, fileInfo, cursorPosition, selectionCount] =
|
||||
statusBar.getLeftTiles().map(tile => tile.getItem());
|
||||
@ -41,18 +35,18 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
describe("when associated with an unsaved buffer", () => it("displays 'untitled' instead of the buffer's path, but still displays the buffer position", function() {
|
||||
waitsForPromise(() => atom.workspace.open());
|
||||
|
||||
return runs(function() {
|
||||
runs(function() {
|
||||
atom.views.performDocumentUpdate();
|
||||
expect(fileInfo.currentPath.textContent).toBe('untitled');
|
||||
expect(cursorPosition.textContent).toBe('1:1');
|
||||
return expect(selectionCount).toBeHidden();
|
||||
expect(selectionCount).toBeHidden();
|
||||
});
|
||||
}));
|
||||
|
||||
describe("when the associated editor's path changes", () => it("updates the path in the status bar", function() {
|
||||
waitsForPromise(() => atom.workspace.open('sample.txt'));
|
||||
|
||||
return runs(() => expect(fileInfo.currentPath.textContent).toBe('sample.txt'));
|
||||
runs(() => expect(fileInfo.currentPath.textContent).toBe('sample.txt'));
|
||||
}));
|
||||
|
||||
describe("when associated with remote file path", function() {
|
||||
@ -65,48 +59,48 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
it("updates the path in the status bar", function() {
|
||||
// The remote path isn't relativized in the test because no remote directory provider is registered.
|
||||
expect(fileInfo.currentPath.textContent).toBe('remote://server:123/folder/remote_file.txt');
|
||||
return expect(fileInfo.currentPath).toBeVisible();
|
||||
expect(fileInfo.currentPath).toBeVisible();
|
||||
});
|
||||
|
||||
it("when the path is clicked", function() {
|
||||
fileInfo.currentPath.click();
|
||||
return expect(atom.clipboard.read()).toBe('/folder/remote_file.txt');
|
||||
expect(atom.clipboard.read()).toBe('/folder/remote_file.txt');
|
||||
});
|
||||
|
||||
return it("calls relativize with the remote URL on shift-click", function() {
|
||||
it("calls relativize with the remote URL on shift-click", function() {
|
||||
const spy = spyOn(atom.project, 'relativize').andReturn('remote_file.txt');
|
||||
const event = new MouseEvent('click', {shiftKey: true});
|
||||
fileInfo.dispatchEvent(event);
|
||||
expect(atom.clipboard.read()).toBe('remote_file.txt');
|
||||
return expect(spy).toHaveBeenCalledWith('remote://server:123/folder/remote_file.txt');
|
||||
expect(spy).toHaveBeenCalledWith('remote://server:123/folder/remote_file.txt');
|
||||
});
|
||||
});
|
||||
|
||||
describe("when file info tile is clicked", () => it("copies the absolute path into the clipboard if available", function() {
|
||||
waitsForPromise(() => atom.workspace.open('sample.txt'));
|
||||
|
||||
return runs(function() {
|
||||
runs(function() {
|
||||
fileInfo.click();
|
||||
return expect(atom.clipboard.read()).toBe(fileInfo.getActiveItem().getPath());
|
||||
expect(atom.clipboard.read()).toBe(fileInfo.getActiveItem().getPath());
|
||||
});
|
||||
}));
|
||||
|
||||
describe("when the file info tile is shift-clicked", () => it("copies the relative path into the clipboard if available", function() {
|
||||
waitsForPromise(() => atom.workspace.open('sample.txt'));
|
||||
|
||||
return runs(function() {
|
||||
runs(function() {
|
||||
const event = new MouseEvent('click', {shiftKey: true});
|
||||
fileInfo.dispatchEvent(event);
|
||||
return expect(atom.clipboard.read()).toBe('sample.txt');
|
||||
expect(atom.clipboard.read()).toBe('sample.txt');
|
||||
});
|
||||
}));
|
||||
|
||||
describe("when path of an unsaved buffer is clicked", () => it("copies the 'untitled' into clipboard", function() {
|
||||
waitsForPromise(() => atom.workspace.open());
|
||||
|
||||
return runs(function() {
|
||||
runs(function() {
|
||||
fileInfo.currentPath.click();
|
||||
return expect(atom.clipboard.read()).toBe('untitled');
|
||||
expect(atom.clipboard.read()).toBe('untitled');
|
||||
});
|
||||
}));
|
||||
|
||||
@ -114,19 +108,19 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
jasmine.attachToDOM(workspaceElement);
|
||||
waitsForPromise(() => atom.workspace.open());
|
||||
|
||||
return runs(() => expect(document.querySelector('.tooltip')).not.toExist());
|
||||
runs(() => expect(document.querySelector('.tooltip')).not.toExist());
|
||||
}));
|
||||
|
||||
describe("when buffer's path is clicked", () => it("displays path tooltip and the tooltip disappears after ~2 seconds", function() {
|
||||
jasmine.attachToDOM(workspaceElement);
|
||||
waitsForPromise(() => atom.workspace.open());
|
||||
|
||||
return runs(function() {
|
||||
runs(function() {
|
||||
fileInfo.currentPath.click();
|
||||
expect(document.querySelector('.tooltip')).toBeVisible();
|
||||
// extra leeway so test won't fail because tooltip disappeared few milliseconds too late
|
||||
advanceClock(2100);
|
||||
return expect(document.querySelector('.tooltip')).not.toExist();
|
||||
expect(document.querySelector('.tooltip')).not.toExist();
|
||||
});
|
||||
}));
|
||||
|
||||
@ -135,9 +129,9 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
jasmine.attachToDOM(workspaceElement);
|
||||
waitsForPromise(() => atom.workspace.open('sample.txt'));
|
||||
|
||||
return runs(function() {
|
||||
runs(function() {
|
||||
fileInfo.currentPath.click();
|
||||
return expect(document.querySelector('.tooltip')).toHaveText(`Copied: ${fileInfo.getActiveItem().getPath()}`);
|
||||
expect(document.querySelector('.tooltip')).toHaveText(`Copied: ${fileInfo.getActiveItem().getPath()}`);
|
||||
});
|
||||
});
|
||||
|
||||
@ -146,20 +140,20 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
dummyView.getPath = () => '/user/path/for/my/file.txt';
|
||||
atom.workspace.getActivePane().activateItem(dummyView);
|
||||
|
||||
return runs(function() {
|
||||
runs(function() {
|
||||
fileInfo.currentPath.click();
|
||||
return expect(document.querySelector('.tooltip')).toHaveText(`Copied: ${dummyView.getPath()}`);
|
||||
expect(document.querySelector('.tooltip')).toHaveText(`Copied: ${dummyView.getPath()}`);
|
||||
});
|
||||
});
|
||||
|
||||
return it("displays a tooltip containing text 'Copied:' for an absolute Windows path", function() {
|
||||
it("displays a tooltip containing text 'Copied:' for an absolute Windows path", function() {
|
||||
jasmine.attachToDOM(workspaceElement);
|
||||
dummyView.getPath = () => 'c:\\user\\path\\for\\my\\file.txt';
|
||||
atom.workspace.getActivePane().activateItem(dummyView);
|
||||
|
||||
return runs(function() {
|
||||
runs(function() {
|
||||
fileInfo.currentPath.click();
|
||||
return expect(document.querySelector('.tooltip')).toHaveText(`Copied: ${dummyView.getPath()}`);
|
||||
expect(document.querySelector('.tooltip')).toHaveText(`Copied: ${dummyView.getPath()}`);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -168,9 +162,9 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
jasmine.attachToDOM(workspaceElement);
|
||||
waitsForPromise(() => atom.workspace.open());
|
||||
|
||||
return runs(function() {
|
||||
runs(function() {
|
||||
fileInfo.currentPath.click();
|
||||
return expect(document.querySelector('.tooltip')).toHaveText("Copied: untitled");
|
||||
expect(document.querySelector('.tooltip')).toHaveText("Copied: untitled");
|
||||
});
|
||||
}));
|
||||
|
||||
@ -194,13 +188,13 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(false);
|
||||
editor.insertText("\n");
|
||||
advanceClock(buffer.stoppedChangingDelay);
|
||||
return expect(fileInfo.classList.contains('buffer-modified')).toBe(true);
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(true);
|
||||
});
|
||||
|
||||
waitsForPromise(() => // TODO - remove this Promise.resolve once atom/atom#14435 lands.
|
||||
Promise.resolve(editor.getBuffer().save()));
|
||||
|
||||
return runs(() => expect(fileInfo.classList.contains('buffer-modified')).toBe(false));
|
||||
runs(() => expect(fileInfo.classList.contains('buffer-modified')).toBe(false));
|
||||
});
|
||||
|
||||
it("disables the buffer modified indicator if the content matches again", function() {
|
||||
@ -210,17 +204,17 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(true);
|
||||
editor.backspace();
|
||||
advanceClock(buffer.stoppedChangingDelay);
|
||||
return expect(fileInfo.classList.contains('buffer-modified')).toBe(false);
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(false);
|
||||
});
|
||||
|
||||
return it("disables the buffer modified indicator when the change is undone", function() {
|
||||
it("disables the buffer modified indicator when the change is undone", function() {
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(false);
|
||||
editor.insertText("\n");
|
||||
advanceClock(buffer.stoppedChangingDelay);
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(true);
|
||||
editor.undo();
|
||||
advanceClock(buffer.stoppedChangingDelay);
|
||||
return expect(fileInfo.classList.contains('buffer-modified')).toBe(false);
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@ -230,24 +224,24 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
|
||||
waitsForPromise(() => atom.workspace.open('sample.txt'));
|
||||
|
||||
return runs(function() {
|
||||
runs(function() {
|
||||
editor = atom.workspace.getActiveTextEditor();
|
||||
editor.insertText("\n");
|
||||
advanceClock(buffer.stoppedChangingDelay);
|
||||
return expect(fileInfo.classList.contains('buffer-modified')).toBe(true);
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
return it("doesn't update the buffer modified indicator for the old buffer", function() {
|
||||
it("doesn't update the buffer modified indicator for the old buffer", function() {
|
||||
const oldBuffer = editor.getBuffer();
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(false);
|
||||
|
||||
waitsForPromise(() => atom.workspace.open('sample.txt'));
|
||||
|
||||
return runs(function() {
|
||||
runs(function() {
|
||||
oldBuffer.setText("new text");
|
||||
advanceClock(buffer.stoppedChangingDelay);
|
||||
return expect(fileInfo.classList.contains('buffer-modified')).toBe(false);
|
||||
expect(fileInfo.classList.contains('buffer-modified')).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -257,21 +251,21 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
jasmine.attachToDOM(workspaceElement);
|
||||
editor.setCursorScreenPosition([1, 2]);
|
||||
atom.views.performDocumentUpdate();
|
||||
return expect(cursorPosition.textContent).toBe('2:3');
|
||||
expect(cursorPosition.textContent).toBe('2:3');
|
||||
});
|
||||
|
||||
return it("does not throw an exception if the cursor is moved as the result of the active pane item changing to a non-editor (regression)", function() {
|
||||
it("does not throw an exception if the cursor is moved as the result of the active pane item changing to a non-editor (regression)", function() {
|
||||
waitsForPromise(() => Promise.resolve(atom.packages.deactivatePackage('status-bar'))); // Wrapped so works with Promise & non-Promise deactivate
|
||||
runs(() => atom.workspace.onDidChangeActivePaneItem(() => editor.setCursorScreenPosition([1, 2])));
|
||||
waitsForPromise(() => atom.packages.activatePackage('status-bar'));
|
||||
return runs(function() {
|
||||
runs(function() {
|
||||
statusBar = workspaceElement.querySelector("status-bar");
|
||||
cursorPosition = statusBar.getLeftTiles()[2].getItem();
|
||||
|
||||
atom.workspace.getActivePane().activateItem(document.createElement('div'));
|
||||
expect(editor.getCursorScreenPosition()).toEqual([1, 2]);
|
||||
atom.views.performDocumentUpdate();
|
||||
return expect(cursorPosition).toBeHidden();
|
||||
expect(cursorPosition).toBeHidden();
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -290,21 +284,21 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
|
||||
editor.setSelectedBufferRange([[0, 0], [1, 30]]);
|
||||
atom.views.performDocumentUpdate();
|
||||
return expect(selectionCount.textContent).toBe("(2, 60)");
|
||||
expect(selectionCount.textContent).toBe("(2, 60)");
|
||||
});
|
||||
|
||||
return it("does not throw an exception if the cursor is moved as the result of the active pane item changing to a non-editor (regression)", function() {
|
||||
it("does not throw an exception if the cursor is moved as the result of the active pane item changing to a non-editor (regression)", function() {
|
||||
waitsForPromise(() => Promise.resolve(atom.packages.deactivatePackage('status-bar'))); // Wrapped so works with Promise & non-Promise deactivate
|
||||
runs(() => atom.workspace.onDidChangeActivePaneItem(() => editor.setSelectedBufferRange([[1, 2], [1, 3]])));
|
||||
waitsForPromise(() => atom.packages.activatePackage('status-bar'));
|
||||
return runs(function() {
|
||||
runs(function() {
|
||||
statusBar = workspaceElement.querySelector("status-bar");
|
||||
selectionCount = statusBar.getLeftTiles()[3].getItem();
|
||||
|
||||
atom.workspace.getActivePane().activateItem(document.createElement('div'));
|
||||
expect(editor.getSelectedBufferRange()).toEqual([[1, 2], [1, 3]]);
|
||||
atom.views.performDocumentUpdate();
|
||||
return expect(selectionCount).toBeHidden();
|
||||
expect(selectionCount).toBeHidden();
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -313,7 +307,7 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
jasmine.attachToDOM(workspaceElement);
|
||||
atom.workspace.getActivePane().activateItem(dummyView);
|
||||
atom.views.performDocumentUpdate();
|
||||
return expect(cursorPosition).toBeHidden();
|
||||
expect(cursorPosition).toBeHidden();
|
||||
}));
|
||||
|
||||
describe("when the active pane item implements getTitle() but not getPath()", () => it("displays the title", function() {
|
||||
@ -321,13 +315,13 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
dummyView.getTitle = () => 'View Title';
|
||||
atom.workspace.getActivePane().activateItem(dummyView);
|
||||
expect(fileInfo.currentPath.textContent).toBe('View Title');
|
||||
return expect(fileInfo.currentPath).toBeVisible();
|
||||
expect(fileInfo.currentPath).toBeVisible();
|
||||
}));
|
||||
|
||||
describe("when the active pane item neither getTitle() nor getPath()", () => it("hides the path view", function() {
|
||||
jasmine.attachToDOM(workspaceElement);
|
||||
atom.workspace.getActivePane().activateItem(dummyView);
|
||||
return expect(fileInfo.currentPath).toBeHidden();
|
||||
expect(fileInfo.currentPath).toBeHidden();
|
||||
}));
|
||||
|
||||
describe("when the active pane item's title changes", () => it("updates the path view with the new title", function() {
|
||||
@ -344,7 +338,7 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
expect(fileInfo.currentPath.textContent).toBe('View Title');
|
||||
dummyView.getTitle = () => 'New Title';
|
||||
for (let callback of Array.from(callbacks)) { callback(); }
|
||||
return expect(fileInfo.currentPath.textContent).toBe('New Title');
|
||||
expect(fileInfo.currentPath.textContent).toBe('New Title');
|
||||
}));
|
||||
|
||||
describe('the cursor position tile', function() {
|
||||
@ -354,7 +348,7 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
jasmine.attachToDOM(workspaceElement);
|
||||
editor.setCursorScreenPosition([1, 2]);
|
||||
atom.views.performDocumentUpdate();
|
||||
return expect(cursorPosition.textContent).toBe('foo 2 bar 3');
|
||||
expect(cursorPosition.textContent).toBe('foo 2 bar 3');
|
||||
});
|
||||
|
||||
it('updates when the configuration changes', function() {
|
||||
@ -365,25 +359,25 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
|
||||
atom.config.set('status-bar.cursorPositionFormat', 'baz %C quux %L');
|
||||
atom.views.performDocumentUpdate();
|
||||
return expect(cursorPosition.textContent).toBe('baz 3 quux 2');
|
||||
expect(cursorPosition.textContent).toBe('baz 3 quux 2');
|
||||
});
|
||||
|
||||
return describe("when clicked", () => it("triggers the go-to-line toggle event", function() {
|
||||
describe("when clicked", () => it("triggers the go-to-line toggle event", function() {
|
||||
const eventHandler = jasmine.createSpy('eventHandler');
|
||||
atom.commands.add('atom-text-editor', 'go-to-line:toggle', eventHandler);
|
||||
cursorPosition.click();
|
||||
return expect(eventHandler).toHaveBeenCalled();
|
||||
expect(eventHandler).toHaveBeenCalled();
|
||||
}));
|
||||
});
|
||||
|
||||
return describe('the selection count tile', function() {
|
||||
describe('the selection count tile', function() {
|
||||
beforeEach(() => atom.config.set('status-bar.selectionCountFormat', '%L foo %C bar selected'));
|
||||
|
||||
it('respects a format string', function() {
|
||||
jasmine.attachToDOM(workspaceElement);
|
||||
editor.setSelectedBufferRange([[0, 0], [1, 30]]);
|
||||
atom.views.performDocumentUpdate();
|
||||
return expect(selectionCount.textContent).toBe("2 foo 60 bar selected");
|
||||
expect(selectionCount.textContent).toBe("2 foo 60 bar selected");
|
||||
});
|
||||
|
||||
it('updates when the configuration changes', function() {
|
||||
@ -394,7 +388,7 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
|
||||
atom.config.set('status-bar.selectionCountFormat', 'Selection: baz %C quux %L');
|
||||
atom.views.performDocumentUpdate();
|
||||
return expect(selectionCount.textContent).toBe("Selection: baz 60 quux 2");
|
||||
expect(selectionCount.textContent).toBe("Selection: baz 60 quux 2");
|
||||
});
|
||||
|
||||
it('does not include the next line if the last selected character is a LF', function() {
|
||||
@ -404,22 +398,22 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
jasmine.attachToDOM(workspaceElement);
|
||||
editor.setSelectedBufferRange([[0, 0], [1, 0]]);
|
||||
atom.views.performDocumentUpdate();
|
||||
return expect(selectionCount.textContent).toBe("1 foo 30 bar selected");
|
||||
expect(selectionCount.textContent).toBe("1 foo 30 bar selected");
|
||||
});
|
||||
|
||||
return it('does not include the next line if the last selected character is CRLF', function() {
|
||||
it('does not include the next line if the last selected character is CRLF', function() {
|
||||
const lineEndingRegExp = /\r\n|\n|\r/g;
|
||||
buffer = editor.getBuffer();
|
||||
buffer.setText(buffer.getText().replace(lineEndingRegExp, '\r\n'));
|
||||
jasmine.attachToDOM(workspaceElement);
|
||||
editor.setSelectedBufferRange([[0, 0], [1, 0]]);
|
||||
atom.views.performDocumentUpdate();
|
||||
return expect(selectionCount.textContent).toBe("1 foo 31 bar selected");
|
||||
expect(selectionCount.textContent).toBe("1 foo 31 bar selected");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return describe("the git tile", function() {
|
||||
describe("the git tile", function() {
|
||||
let gitView = null;
|
||||
|
||||
const hover = function(element, fn) {
|
||||
@ -458,16 +452,16 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
waitsForPromise(() => atom.workspace.open(filePath)
|
||||
.then(() => repo.refreshStatus()));
|
||||
|
||||
return runs(function() {
|
||||
runs(function() {
|
||||
const behindElement = document.body.querySelector(".commits-behind-label");
|
||||
const aheadElement = document.body.querySelector(".commits-ahead-label");
|
||||
expect(aheadElement).toBeVisible();
|
||||
expect(behindElement).toBeVisible();
|
||||
return expect(aheadElement.textContent).toContain('1');
|
||||
expect(aheadElement.textContent).toContain('1');
|
||||
});
|
||||
});
|
||||
|
||||
return it("stays hidden when no commits can be pushed/pulled", function() {
|
||||
it("stays hidden when no commits can be pushed/pulled", function() {
|
||||
const workingDir = setupWorkingDir('no-ahead-behind-repo');
|
||||
atom.project.setPaths([workingDir]);
|
||||
const filePath = atom.project.getDirectories()[0].resolve('a.txt');
|
||||
@ -476,11 +470,11 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
waitsForPromise(() => atom.workspace.open(filePath)
|
||||
.then(() => repo.refreshStatus()));
|
||||
|
||||
return runs(function() {
|
||||
runs(function() {
|
||||
const behindElement = document.body.querySelector(".commits-behind-label");
|
||||
const aheadElement = document.body.querySelector(".commits-ahead-label");
|
||||
expect(aheadElement).not.toBeVisible();
|
||||
return expect(behindElement).not.toBeVisible();
|
||||
expect(behindElement).not.toBeVisible();
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -512,7 +506,7 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
return atom.workspace.getActivePane().activateItem(dummyView);
|
||||
});
|
||||
|
||||
return runs(() => expect(gitView.branchArea).not.toBeVisible());
|
||||
runs(() => expect(gitView.branchArea).not.toBeVisible());
|
||||
});
|
||||
|
||||
it("displays the current branch tooltip", function() {
|
||||
@ -520,7 +514,7 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
|
||||
waitsForPromise(() => atom.workspace.open('a.txt'));
|
||||
|
||||
return runs(function() {
|
||||
runs(function() {
|
||||
const currentBranch = atom.project.getRepositories()[0].getShortHead();
|
||||
return hover(gitView.branchArea, () => expect(document.body.querySelector(".tooltip").innerText)
|
||||
.toBe(`On branch ${currentBranch}`));
|
||||
@ -532,17 +526,17 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
|
||||
waitsForPromise(() => atom.workspace.open(path.join(os.tmpdir(), 'temp.txt')));
|
||||
|
||||
return runs(() => expect(gitView.branchArea).toBeHidden());
|
||||
runs(() => expect(gitView.branchArea).toBeHidden());
|
||||
});
|
||||
|
||||
return it("doesn't display the current branch for a file outside the current project", function() {
|
||||
it("doesn't display the current branch for a file outside the current project", function() {
|
||||
waitsForPromise(() => atom.workspace.open(path.join(os.tmpdir(), 'atom-specs', 'not-in-project.txt')));
|
||||
|
||||
return runs(() => expect(gitView.branchArea).toBeHidden());
|
||||
runs(() => expect(gitView.branchArea).toBeHidden());
|
||||
});
|
||||
});
|
||||
|
||||
return describe("the git status label", function() {
|
||||
describe("the git status label", function() {
|
||||
let [repo, filePath, originalPathText, newPath, ignorePath, ignoredPath, projectPath] = [];
|
||||
|
||||
beforeEach(function() {
|
||||
@ -577,7 +571,7 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
fs.writeFileSync(filePath, "i've changed for the worse");
|
||||
return repo.refreshStatus();
|
||||
}));
|
||||
return runs(() => expect(gitView.gitStatusIcon).toHaveClass('icon-diff-modified'));
|
||||
runs(() => expect(gitView.gitStatusIcon).toHaveClass('icon-diff-modified'));
|
||||
});
|
||||
|
||||
it("displays the 1 line added and not committed tooltip", function() {
|
||||
@ -587,7 +581,7 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
return repo.refreshStatus();
|
||||
}));
|
||||
|
||||
return runs(() => hover(gitView.gitStatusIcon, () => expect(document.body.querySelector(".tooltip").innerText)
|
||||
runs(() => hover(gitView.gitStatusIcon, () => expect(document.body.querySelector(".tooltip").innerText)
|
||||
.toBe("1 line added to this file not yet committed")));
|
||||
});
|
||||
|
||||
@ -598,7 +592,7 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
return repo.refreshStatus();
|
||||
}));
|
||||
|
||||
return runs(() => hover(gitView.gitStatusIcon, () => expect(document.body.querySelector(".tooltip").innerText)
|
||||
runs(() => hover(gitView.gitStatusIcon, () => expect(document.body.querySelector(".tooltip").innerText)
|
||||
.toBe("2 lines added to this file not yet committed")));
|
||||
});
|
||||
|
||||
@ -606,14 +600,14 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
waitsForPromise(() => atom.workspace.open(filePath)
|
||||
.then(() => repo.refreshStatus()));
|
||||
|
||||
return runs(() => expect(gitView.gitStatusIcon).toHaveText(''));
|
||||
runs(() => expect(gitView.gitStatusIcon).toHaveText(''));
|
||||
});
|
||||
|
||||
it("displays the new icon for a new file", function() {
|
||||
waitsForPromise(() => atom.workspace.open(newPath)
|
||||
.then(() => repo.refreshStatus()));
|
||||
|
||||
return runs(function() {
|
||||
runs(function() {
|
||||
expect(gitView.gitStatusIcon).toHaveClass('icon-diff-added');
|
||||
return hover(gitView.gitStatusIcon, () => expect(document.body.querySelector(".tooltip").innerText)
|
||||
.toBe("1 line in this new file not yet committed"));
|
||||
@ -624,7 +618,7 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
waitsForPromise(() => atom.workspace.open(newPath)
|
||||
.then(() => repo.refreshStatus()));
|
||||
|
||||
return runs(() => hover(gitView.gitStatusIcon, () => expect(document.body.querySelector(".tooltip").innerText)
|
||||
runs(() => hover(gitView.gitStatusIcon, () => expect(document.body.querySelector(".tooltip").innerText)
|
||||
.toBe("1 line in this new file not yet committed")));
|
||||
});
|
||||
|
||||
@ -633,14 +627,14 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
waitsForPromise(() => atom.workspace.open(newPath)
|
||||
.then(() => repo.refreshStatus()));
|
||||
|
||||
return runs(() => hover(gitView.gitStatusIcon, () => expect(document.body.querySelector(".tooltip").innerText)
|
||||
runs(() => hover(gitView.gitStatusIcon, () => expect(document.body.querySelector(".tooltip").innerText)
|
||||
.toBe("2 lines in this new file not yet committed")));
|
||||
});
|
||||
|
||||
it("displays the ignored icon for an ignored file", function() {
|
||||
waitsForPromise(() => atom.workspace.open(ignoredPath));
|
||||
|
||||
return runs(function() {
|
||||
runs(function() {
|
||||
expect(gitView.gitStatusIcon).toHaveClass('icon-diff-ignored');
|
||||
return hover(gitView.gitStatusIcon, () => expect(document.body.querySelector(".tooltip").innerText)
|
||||
.toBe("File is ignored by git"));
|
||||
@ -653,14 +647,14 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
fs.writeFileSync(filePath, "i've changed for the worse");
|
||||
return repo.refreshStatus();
|
||||
}));
|
||||
return runs(function() {
|
||||
runs(function() {
|
||||
expect(gitView.gitStatusIcon).toHaveClass('icon-diff-modified');
|
||||
|
||||
waitsForPromise(function() {
|
||||
fs.writeFileSync(filePath, originalPathText);
|
||||
return repo.refreshStatus();
|
||||
});
|
||||
return runs(() => expect(gitView.gitStatusIcon).not.toHaveClass('icon-diff-modified'));
|
||||
runs(() => expect(gitView.gitStatusIcon).not.toHaveClass('icon-diff-modified'));
|
||||
});
|
||||
});
|
||||
|
||||
@ -670,20 +664,20 @@ describe("Built-in Status Bar Tiles", function() {
|
||||
fs.writeFileSync(filePath, "i've changed for the worse");
|
||||
return repo.refreshStatus();
|
||||
}));
|
||||
return runs(() => expect(gitView.gitStatusIcon).toHaveText('+1'));
|
||||
runs(() => expect(gitView.gitStatusIcon).toHaveText('+1'));
|
||||
});
|
||||
|
||||
it("displays the diff stat for new files", function() {
|
||||
waitsForPromise(() => atom.workspace.open(newPath)
|
||||
.then(() => repo.refreshStatus()));
|
||||
|
||||
return runs(() => expect(gitView.gitStatusIcon).toHaveText('+1'));
|
||||
runs(() => expect(gitView.gitStatusIcon).toHaveText('+1'));
|
||||
});
|
||||
|
||||
return it("does not display for files not in the current project", function() {
|
||||
it("does not display for files not in the current project", function() {
|
||||
waitsForPromise(() => atom.workspace.open('/tmp/atom-specs/not-in-project.txt'));
|
||||
|
||||
return runs(() => expect(gitView.gitStatusIcon).toBeHidden());
|
||||
runs(() => expect(gitView.gitStatusIcon).toBeHidden());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,111 +0,0 @@
|
||||
describe "Status Bar package", ->
|
||||
[editor, statusBar, statusBarService, workspaceElement, mainModule] = []
|
||||
|
||||
beforeEach ->
|
||||
workspaceElement = atom.views.getView(atom.workspace)
|
||||
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage('status-bar').then (pack) ->
|
||||
statusBar = workspaceElement.querySelector("status-bar")
|
||||
statusBarService = pack.mainModule.provideStatusBar()
|
||||
{mainModule} = pack
|
||||
|
||||
describe "@activate()", ->
|
||||
it "appends only one status bar", ->
|
||||
expect(workspaceElement.querySelectorAll('status-bar').length).toBe 1
|
||||
atom.workspace.getActivePane().splitRight(copyActiveItem: true)
|
||||
expect(workspaceElement.querySelectorAll('status-bar').length).toBe 1
|
||||
|
||||
describe "@deactivate()", ->
|
||||
it "removes the status bar view", ->
|
||||
waitsForPromise ->
|
||||
Promise.resolve(atom.packages.deactivatePackage('status-bar')) # Wrapped so works with Promise & non-Promise deactivate
|
||||
runs ->
|
||||
expect(workspaceElement.querySelector('status-bar')).toBeNull()
|
||||
|
||||
describe "isVisible option", ->
|
||||
beforeEach ->
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
|
||||
describe "when it is true", ->
|
||||
beforeEach ->
|
||||
atom.config.set 'status-bar.isVisible', true
|
||||
|
||||
it "shows status bar", ->
|
||||
expect(workspaceElement.querySelector('status-bar').parentNode).toBeVisible()
|
||||
|
||||
describe "when it is false", ->
|
||||
beforeEach ->
|
||||
atom.config.set 'status-bar.isVisible', false
|
||||
|
||||
it "hides status bar", ->
|
||||
expect(workspaceElement.querySelector('status-bar').parentNode).not.toBeVisible()
|
||||
|
||||
describe "when status-bar:toggle is triggered", ->
|
||||
beforeEach ->
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
atom.config.set 'status-bar.isVisible', true
|
||||
|
||||
it "hides or shows the status bar", ->
|
||||
atom.commands.dispatch(workspaceElement, 'status-bar:toggle')
|
||||
expect(workspaceElement.querySelector('status-bar').parentNode).not.toBeVisible()
|
||||
atom.commands.dispatch(workspaceElement, 'status-bar:toggle')
|
||||
expect(workspaceElement.querySelector('status-bar').parentNode).toBeVisible()
|
||||
|
||||
it "toggles the value of isVisible in config file", ->
|
||||
expect(atom.config.get 'status-bar.isVisible').toBe true
|
||||
atom.commands.dispatch(workspaceElement, 'status-bar:toggle')
|
||||
expect(atom.config.get 'status-bar.isVisible').toBe false
|
||||
atom.commands.dispatch(workspaceElement, 'status-bar:toggle')
|
||||
expect(atom.config.get 'status-bar.isVisible').toBe true
|
||||
|
||||
describe "full-width setting", ->
|
||||
[containers] = []
|
||||
|
||||
beforeEach ->
|
||||
containers = atom.workspace.panelContainers
|
||||
jasmine.attachToDOM(workspaceElement)
|
||||
|
||||
waitsForPromise ->
|
||||
atom.workspace.open('sample.js')
|
||||
|
||||
it "expects the setting to be enabled by default", ->
|
||||
expect(atom.config.get('status-bar.fullWidth')).toBeTruthy()
|
||||
expect(containers.footer.panels).toContain(mainModule.statusBarPanel)
|
||||
|
||||
describe "when setting is changed", ->
|
||||
it "fits status bar to editor's width", ->
|
||||
atom.config.set('status-bar.fullWidth', false)
|
||||
expect(containers.bottom.panels).toContain(mainModule.statusBarPanel)
|
||||
expect(containers.footer.panels).not.toContain(mainModule.statusBarPanel)
|
||||
|
||||
it "restores the status-bar location when re-enabling setting", ->
|
||||
atom.config.set('status-bar.fullWidth', true)
|
||||
expect(containers.footer.panels).toContain(mainModule.statusBarPanel)
|
||||
expect(containers.bottom.panels).not.toContain(mainModule.statusBarPanel)
|
||||
|
||||
describe "the 'status-bar' service", ->
|
||||
it "allows tiles to be added, removed, and retrieved", ->
|
||||
dummyView = document.createElement("div")
|
||||
tile = statusBarService.addLeftTile(item: dummyView)
|
||||
expect(statusBar).toContain(dummyView)
|
||||
expect(statusBarService.getLeftTiles()).toContain(tile)
|
||||
tile.destroy()
|
||||
expect(statusBar).not.toContain(dummyView)
|
||||
expect(statusBarService.getLeftTiles()).not.toContain(tile)
|
||||
|
||||
dummyView = document.createElement("div")
|
||||
tile = statusBarService.addRightTile(item: dummyView)
|
||||
expect(statusBar).toContain(dummyView)
|
||||
expect(statusBarService.getRightTiles()).toContain(tile)
|
||||
tile.destroy()
|
||||
expect(statusBar).not.toContain(dummyView)
|
||||
expect(statusBarService.getRightTiles()).not.toContain(tile)
|
||||
|
||||
it "allows the git info tile to be disabled", ->
|
||||
getGitInfoTile = ->
|
||||
statusBar.getRightTiles().find((tile) -> tile.item.matches('.git-view'))
|
||||
|
||||
expect(getGitInfoTile()).not.toBeUndefined()
|
||||
statusBarService.disableGitInfoTile()
|
||||
expect(getGitInfoTile()).toBeUndefined()
|
@ -1,15 +1,11 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
|
||||
describe("Status Bar package", function() {
|
||||
let [editor, statusBar, statusBarService, workspaceElement, mainModule] = [];
|
||||
|
||||
beforeEach(function() {
|
||||
workspaceElement = atom.views.getView(atom.workspace);
|
||||
|
||||
return waitsForPromise(() => atom.packages.activatePackage('status-bar').then(function(pack) {
|
||||
waitsForPromise(() => atom.packages.activatePackage('status-bar').then(function(pack) {
|
||||
statusBar = workspaceElement.querySelector("status-bar");
|
||||
statusBarService = pack.mainModule.provideStatusBar();
|
||||
return ({mainModule} = pack);
|
||||
@ -19,12 +15,12 @@ describe("Status Bar package", function() {
|
||||
describe("@activate()", () => it("appends only one status bar", function() {
|
||||
expect(workspaceElement.querySelectorAll('status-bar').length).toBe(1);
|
||||
atom.workspace.getActivePane().splitRight({copyActiveItem: true});
|
||||
return expect(workspaceElement.querySelectorAll('status-bar').length).toBe(1);
|
||||
expect(workspaceElement.querySelectorAll('status-bar').length).toBe(1);
|
||||
}));
|
||||
|
||||
describe("@deactivate()", () => it("removes the status bar view", function() {
|
||||
waitsForPromise(() => Promise.resolve(atom.packages.deactivatePackage('status-bar'))); // Wrapped so works with Promise & non-Promise deactivate
|
||||
return runs(() => expect(workspaceElement.querySelector('status-bar')).toBeNull());
|
||||
runs(() => expect(workspaceElement.querySelector('status-bar')).toBeNull());
|
||||
}));
|
||||
|
||||
describe("isVisible option", function() {
|
||||
@ -33,13 +29,13 @@ describe("Status Bar package", function() {
|
||||
describe("when it is true", function() {
|
||||
beforeEach(() => atom.config.set('status-bar.isVisible', true));
|
||||
|
||||
return it("shows status bar", () => expect(workspaceElement.querySelector('status-bar').parentNode).toBeVisible());
|
||||
it("shows status bar", () => expect(workspaceElement.querySelector('status-bar').parentNode).toBeVisible());
|
||||
});
|
||||
|
||||
return describe("when it is false", function() {
|
||||
describe("when it is false", function() {
|
||||
beforeEach(() => atom.config.set('status-bar.isVisible', false));
|
||||
|
||||
return it("hides status bar", () => expect(workspaceElement.querySelector('status-bar').parentNode).not.toBeVisible());
|
||||
it("hides status bar", () => expect(workspaceElement.querySelector('status-bar').parentNode).not.toBeVisible());
|
||||
});
|
||||
});
|
||||
|
||||
@ -53,15 +49,15 @@ describe("Status Bar package", function() {
|
||||
atom.commands.dispatch(workspaceElement, 'status-bar:toggle');
|
||||
expect(workspaceElement.querySelector('status-bar').parentNode).not.toBeVisible();
|
||||
atom.commands.dispatch(workspaceElement, 'status-bar:toggle');
|
||||
return expect(workspaceElement.querySelector('status-bar').parentNode).toBeVisible();
|
||||
expect(workspaceElement.querySelector('status-bar').parentNode).toBeVisible();
|
||||
});
|
||||
|
||||
return it("toggles the value of isVisible in config file", function() {
|
||||
it("toggles the value of isVisible in config file", function() {
|
||||
expect(atom.config.get('status-bar.isVisible')).toBe(true);
|
||||
atom.commands.dispatch(workspaceElement, 'status-bar:toggle');
|
||||
expect(atom.config.get('status-bar.isVisible')).toBe(false);
|
||||
atom.commands.dispatch(workspaceElement, 'status-bar:toggle');
|
||||
return expect(atom.config.get('status-bar.isVisible')).toBe(true);
|
||||
expect(atom.config.get('status-bar.isVisible')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@ -77,25 +73,25 @@ describe("Status Bar package", function() {
|
||||
|
||||
it("expects the setting to be enabled by default", function() {
|
||||
expect(atom.config.get('status-bar.fullWidth')).toBeTruthy();
|
||||
return expect(containers.footer.panels).toContain(mainModule.statusBarPanel);
|
||||
expect(containers.footer.panels).toContain(mainModule.statusBarPanel);
|
||||
});
|
||||
|
||||
return describe("when setting is changed", function() {
|
||||
describe("when setting is changed", function() {
|
||||
it("fits status bar to editor's width", function() {
|
||||
atom.config.set('status-bar.fullWidth', false);
|
||||
expect(containers.bottom.panels).toContain(mainModule.statusBarPanel);
|
||||
return expect(containers.footer.panels).not.toContain(mainModule.statusBarPanel);
|
||||
expect(containers.footer.panels).not.toContain(mainModule.statusBarPanel);
|
||||
});
|
||||
|
||||
return it("restores the status-bar location when re-enabling setting", function() {
|
||||
it("restores the status-bar location when re-enabling setting", function() {
|
||||
atom.config.set('status-bar.fullWidth', true);
|
||||
expect(containers.footer.panels).toContain(mainModule.statusBarPanel);
|
||||
return expect(containers.bottom.panels).not.toContain(mainModule.statusBarPanel);
|
||||
expect(containers.bottom.panels).not.toContain(mainModule.statusBarPanel);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return describe("the 'status-bar' service", function() {
|
||||
describe("the 'status-bar' service", function() {
|
||||
it("allows tiles to be added, removed, and retrieved", function() {
|
||||
let dummyView = document.createElement("div");
|
||||
let tile = statusBarService.addLeftTile({item: dummyView});
|
||||
@ -111,15 +107,15 @@ describe("Status Bar package", function() {
|
||||
expect(statusBarService.getRightTiles()).toContain(tile);
|
||||
tile.destroy();
|
||||
expect(statusBar).not.toContain(dummyView);
|
||||
return expect(statusBarService.getRightTiles()).not.toContain(tile);
|
||||
expect(statusBarService.getRightTiles()).not.toContain(tile);
|
||||
});
|
||||
|
||||
return it("allows the git info tile to be disabled", function() {
|
||||
it("allows the git info tile to be disabled", function() {
|
||||
const getGitInfoTile = () => statusBar.getRightTiles().find(tile => tile.item.matches('.git-view'));
|
||||
|
||||
expect(getGitInfoTile()).not.toBeUndefined();
|
||||
statusBarService.disableGitInfoTile();
|
||||
return expect(getGitInfoTile()).toBeUndefined();
|
||||
expect(getGitInfoTile()).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,103 +0,0 @@
|
||||
StatusBarView = require '../lib/status-bar-view'
|
||||
|
||||
describe "StatusBarView", ->
|
||||
statusBarView = null
|
||||
|
||||
class TestItem
|
||||
constructor: (@id) ->
|
||||
|
||||
beforeEach ->
|
||||
statusBarView = new StatusBarView()
|
||||
|
||||
atom.views.addViewProvider TestItem, (model) ->
|
||||
element = document.createElement("item-view")
|
||||
element.model = model
|
||||
element
|
||||
|
||||
describe "::addLeftTile({item, priority})", ->
|
||||
it "appends the view for the given item to its left side", ->
|
||||
testItem1 = new TestItem(1)
|
||||
testItem2 = new TestItem(2)
|
||||
testItem3 = new TestItem(3)
|
||||
|
||||
tile1 = statusBarView.addLeftTile(item: testItem1, priority: 10)
|
||||
tile2 = statusBarView.addLeftTile(item: testItem2, priority: 30)
|
||||
tile3 = statusBarView.addLeftTile(item: testItem3, priority: 20)
|
||||
|
||||
{leftPanel} = statusBarView
|
||||
|
||||
expect(leftPanel.children[0].nodeName).toBe("ITEM-VIEW")
|
||||
expect(leftPanel.children[1].nodeName).toBe("ITEM-VIEW")
|
||||
expect(leftPanel.children[2].nodeName).toBe("ITEM-VIEW")
|
||||
|
||||
expect(leftPanel.children[0].model).toBe(testItem1)
|
||||
expect(leftPanel.children[1].model).toBe(testItem3)
|
||||
expect(leftPanel.children[2].model).toBe(testItem2)
|
||||
|
||||
expect(statusBarView.getLeftTiles()).toEqual([tile1, tile3, tile2])
|
||||
expect(tile1.getPriority()).toBe(10)
|
||||
expect(tile1.getItem()).toBe(testItem1)
|
||||
|
||||
it "allows the view to be removed", ->
|
||||
testItem = new TestItem(1)
|
||||
tile = statusBarView.addLeftTile(item: testItem, priority: 10)
|
||||
tile.destroy()
|
||||
expect(statusBarView.leftPanel.children.length).toBe(0)
|
||||
|
||||
statusBarView.addLeftTile(item: testItem, priority: 9)
|
||||
|
||||
describe "when no priority is given", ->
|
||||
it "appends the item", ->
|
||||
testItem1 = new TestItem(1)
|
||||
testItem2 = new TestItem(2)
|
||||
|
||||
statusBarView.addLeftTile(item: testItem1, priority: 1000)
|
||||
statusBarView.addLeftTile(item: testItem2)
|
||||
|
||||
{leftPanel} = statusBarView
|
||||
expect(leftPanel.children[0].model).toBe(testItem1)
|
||||
expect(leftPanel.children[1].model).toBe(testItem2)
|
||||
|
||||
describe "::addRightTile({item, priority})", ->
|
||||
it "appends the view for the given item to its right side", ->
|
||||
testItem1 = new TestItem(1)
|
||||
testItem2 = new TestItem(2)
|
||||
testItem3 = new TestItem(3)
|
||||
|
||||
tile1 = statusBarView.addRightTile(item: testItem1, priority: 10)
|
||||
tile2 = statusBarView.addRightTile(item: testItem2, priority: 30)
|
||||
tile3 = statusBarView.addRightTile(item: testItem3, priority: 20)
|
||||
|
||||
{rightPanel} = statusBarView
|
||||
|
||||
expect(rightPanel.children[0].nodeName).toBe("ITEM-VIEW")
|
||||
expect(rightPanel.children[1].nodeName).toBe("ITEM-VIEW")
|
||||
expect(rightPanel.children[2].nodeName).toBe("ITEM-VIEW")
|
||||
|
||||
expect(rightPanel.children[0].model).toBe(testItem2)
|
||||
expect(rightPanel.children[1].model).toBe(testItem3)
|
||||
expect(rightPanel.children[2].model).toBe(testItem1)
|
||||
|
||||
expect(statusBarView.getRightTiles()).toEqual([tile2, tile3, tile1])
|
||||
expect(tile1.getPriority()).toBe(10)
|
||||
expect(tile1.getItem()).toBe(testItem1)
|
||||
|
||||
it "allows the view to be removed", ->
|
||||
testItem = new TestItem(1)
|
||||
disposable = statusBarView.addRightTile(item: testItem, priority: 10)
|
||||
disposable.destroy()
|
||||
expect(statusBarView.rightPanel.children.length).toBe(0)
|
||||
|
||||
statusBarView.addRightTile(item: testItem, priority: 11)
|
||||
|
||||
describe "when no priority is given", ->
|
||||
it "prepends the item", ->
|
||||
testItem1 = new TestItem(1, priority: 1000)
|
||||
testItem2 = new TestItem(2)
|
||||
|
||||
statusBarView.addRightTile(item: testItem1, priority: 1000)
|
||||
statusBarView.addRightTile(item: testItem2)
|
||||
|
||||
{rightPanel} = statusBarView
|
||||
expect(rightPanel.children[0].model).toBe(testItem2)
|
||||
expect(rightPanel.children[1].model).toBe(testItem1)
|
@ -1,8 +1,4 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
|
||||
const StatusBarView = require('../lib/status-bar-view');
|
||||
|
||||
describe("StatusBarView", function() {
|
||||
@ -17,7 +13,7 @@ describe("StatusBarView", function() {
|
||||
beforeEach(function() {
|
||||
statusBarView = new StatusBarView();
|
||||
|
||||
return atom.views.addViewProvider(TestItem, function(model) {
|
||||
atom.views.addViewProvider(TestItem, function(model) {
|
||||
const element = document.createElement("item-view");
|
||||
element.model = model;
|
||||
return element;
|
||||
@ -46,7 +42,7 @@ describe("StatusBarView", function() {
|
||||
|
||||
expect(statusBarView.getLeftTiles()).toEqual([tile1, tile3, tile2]);
|
||||
expect(tile1.getPriority()).toBe(10);
|
||||
return expect(tile1.getItem()).toBe(testItem1);
|
||||
expect(tile1.getItem()).toBe(testItem1);
|
||||
});
|
||||
|
||||
it("allows the view to be removed", function() {
|
||||
@ -58,7 +54,7 @@ describe("StatusBarView", function() {
|
||||
return statusBarView.addLeftTile({item: testItem, priority: 9});
|
||||
});
|
||||
|
||||
return describe("when no priority is given", () => it("appends the item", function() {
|
||||
describe("when no priority is given", () => it("appends the item", function() {
|
||||
const testItem1 = new TestItem(1);
|
||||
const testItem2 = new TestItem(2);
|
||||
|
||||
@ -67,11 +63,11 @@ describe("StatusBarView", function() {
|
||||
|
||||
const {leftPanel} = statusBarView;
|
||||
expect(leftPanel.children[0].model).toBe(testItem1);
|
||||
return expect(leftPanel.children[1].model).toBe(testItem2);
|
||||
expect(leftPanel.children[1].model).toBe(testItem2);
|
||||
}));
|
||||
});
|
||||
|
||||
return describe("::addRightTile({item, priority})", function() {
|
||||
describe("::addRightTile({item, priority})", function() {
|
||||
it("appends the view for the given item to its right side", function() {
|
||||
const testItem1 = new TestItem(1);
|
||||
const testItem2 = new TestItem(2);
|
||||
@ -93,7 +89,7 @@ describe("StatusBarView", function() {
|
||||
|
||||
expect(statusBarView.getRightTiles()).toEqual([tile2, tile3, tile1]);
|
||||
expect(tile1.getPriority()).toBe(10);
|
||||
return expect(tile1.getItem()).toBe(testItem1);
|
||||
expect(tile1.getItem()).toBe(testItem1);
|
||||
});
|
||||
|
||||
it("allows the view to be removed", function() {
|
||||
@ -105,7 +101,7 @@ describe("StatusBarView", function() {
|
||||
return statusBarView.addRightTile({item: testItem, priority: 11});
|
||||
});
|
||||
|
||||
return describe("when no priority is given", () => it("prepends the item", function() {
|
||||
describe("when no priority is given", () => it("prepends the item", function() {
|
||||
const testItem1 = new TestItem(1, {priority: 1000});
|
||||
const testItem2 = new TestItem(2);
|
||||
|
||||
@ -114,7 +110,7 @@ describe("StatusBarView", function() {
|
||||
|
||||
const {rightPanel} = statusBarView;
|
||||
expect(rightPanel.children[0].model).toBe(testItem2);
|
||||
return expect(rightPanel.children[1].model).toBe(testItem1);
|
||||
expect(rightPanel.children[1].model).toBe(testItem1);
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user