mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-13 08:44:12 +03:00
Merge branch 'master' of github.com:probablycorey/Atomicity
Conflicts: src/atom/project.coffee
This commit is contained in:
commit
192166d61a
@ -14,28 +14,30 @@ describe "App", ->
|
||||
|
||||
describe "open", ->
|
||||
describe "when opening a filePath", ->
|
||||
it "loads a buffer with filePath contents and displays it in a new window", ->
|
||||
it "displays it in a new window", ->
|
||||
filePath = require.resolve 'fixtures/sample.txt'
|
||||
expect(app.windows().length).toBe 0
|
||||
|
||||
app.open filePath
|
||||
|
||||
expect(app.windows().length).toBe 1
|
||||
newWindow = app.windows()[0]
|
||||
|
||||
it "loads a buffer with filePath contents", ->
|
||||
filePath = require.resolve 'fixtures/sample.txt'
|
||||
|
||||
app.open filePath
|
||||
|
||||
newWindow = app.windows()[0]
|
||||
expect(newWindow.rootView.editor.buffer.url).toEqual filePath
|
||||
expect(newWindow.rootView.editor.buffer.getText()).toEqual fs.read(filePath)
|
||||
|
||||
describe "when opening a dirPath", ->
|
||||
it "loads an empty buffer", ->
|
||||
dirPath = require.resolve 'fixtures'
|
||||
expect(app.windows().length).toBe 0
|
||||
|
||||
app.open dirPath
|
||||
|
||||
expect(app.windows().length).toBe 1
|
||||
newWindow = app.windows()[0]
|
||||
|
||||
expect(newWindow.rootView.editor.buffer.url).toBeUndefined
|
||||
expect(newWindow.rootView.editor.buffer.getText()).toBe ""
|
||||
|
||||
|
@ -59,11 +59,17 @@ describe 'FileFinder', ->
|
||||
expect(finder.find('li:last')).toHaveClass "selected"
|
||||
|
||||
describe "select", ->
|
||||
it "when an file is selected atom.open is called", ->
|
||||
spyOn(atom, 'open')
|
||||
selectedCallback = jasmine.createSpy 'selected'
|
||||
|
||||
beforeEach ->
|
||||
finder = FileFinder.build {urls, selected: selectedCallback}
|
||||
|
||||
it "when a file is selected Editor.open is called", ->
|
||||
spyOn(finder, 'remove')
|
||||
finder.moveDown()
|
||||
finder.select()
|
||||
expect(atom.open).toHaveBeenCalledWith(urls[1])
|
||||
expect(selectedCallback).toHaveBeenCalledWith(urls[1])
|
||||
expect(finder.remove).toHaveBeenCalled()
|
||||
|
||||
it "when no file is selected, does nothing", ->
|
||||
spyOn(atom, 'open')
|
||||
|
@ -8,8 +8,7 @@ describe "Project", ->
|
||||
|
||||
describe ".getFilePaths()", ->
|
||||
it "returns a promise which resolves to a list of all file urls in the project, recursively", ->
|
||||
expectedPaths = for url in fs.list(project.url, true) when fs.isFile url
|
||||
url.replace project.url, ''
|
||||
expectedPaths = (url for url in fs.list(project.url, true) when fs.isFile url)
|
||||
|
||||
waitsForPromise ->
|
||||
project.getFilePaths().done (result) ->
|
||||
|
@ -55,14 +55,6 @@ describe "RootView", ->
|
||||
runs ->
|
||||
expect(rootView.fileFinder.urlList.children('li').length).toBe 3
|
||||
|
||||
it "removes common path prefix from files", ->
|
||||
waitsForPromise ->
|
||||
rootView.toggleFileFinder()
|
||||
|
||||
runs ->
|
||||
commonPathPattern = new RegExp("^" + fs.directory(url))
|
||||
expect(rootView.fileFinder.urlList.children('li:first').text()).not.toMatch commonPathPattern
|
||||
|
||||
describe "when there is no project", ->
|
||||
beforeEach ->
|
||||
rootView = RootView.build()
|
||||
|
@ -14,7 +14,7 @@ class FileFinder extends Template
|
||||
urls: null
|
||||
maxResults: null
|
||||
|
||||
initialize: ({@urls}) ->
|
||||
initialize: ({@urls, @selected}) ->
|
||||
@maxResults = 10
|
||||
|
||||
@populateUrlList()
|
||||
@ -34,8 +34,8 @@ class FileFinder extends Template
|
||||
|
||||
select: ->
|
||||
filePath = @findSelectedLi().text()
|
||||
atom.open filePath if filePath
|
||||
|
||||
@selected(filePath) if filePath and @selected
|
||||
@remove()
|
||||
|
||||
moveUp: ->
|
||||
@findSelectedLi()
|
||||
|
@ -6,7 +6,5 @@ class Project
|
||||
constructor: (@url) ->
|
||||
|
||||
getFilePaths: ->
|
||||
projectUrl = @url
|
||||
fs.async.listFiles(@url, true).pipe (urls) ->
|
||||
url.replace(projectUrl, "") for url in urls
|
||||
fs.async.listFiles(@url, true)
|
||||
|
||||
|
@ -33,11 +33,11 @@ class RootView extends Template
|
||||
toggleFileFinder: ->
|
||||
return unless @project
|
||||
|
||||
if @fileFinder
|
||||
if @fileFinder and @fileFinder.parent()[0]
|
||||
@fileFinder.remove()
|
||||
@fileFinder = null
|
||||
else
|
||||
@project.getFilePaths().done (urls) =>
|
||||
@fileFinder = FileFinder.build({urls})
|
||||
@fileFinder = FileFinder.build({urls, selected: (url) => @editor.open(url)})
|
||||
@addPane(@fileFinder)
|
||||
@fileFinder.input.focus()
|
||||
|
Loading…
Reference in New Issue
Block a user