Address comments + add tests

This commit is contained in:
Mostafa Eweda
2015-05-19 17:10:45 -07:00
parent 506dbfd098
commit c3552c95bc
4 changed files with 20 additions and 4 deletions

View File

@@ -31,6 +31,12 @@ describe "DefaultDirectoryProvider", ->
directory = provider.directoryForURISync(file)
expect(directory.getPath()).toEqual tmp
it "creates a Directory with a path as a uri when passed a uri", ->
provider = new DefaultDirectoryProvider()
uri = 'remote://server:6792/path/to/a/dir'
directory = provider.directoryForURISync(uri)
expect(directory.getPath()).toEqual uri
describe ".directoryForURI(uri)", ->
it "returns a Promise that resolves to a Directory with a path that matches the uri", ->
provider = new DefaultDirectoryProvider()

View File

@@ -293,3 +293,14 @@ describe "Window", ->
pathToOpen = __dirname
atom.getCurrentWindow().send 'message', 'open-locations', [{pathToOpen}]
expect(atom.workspace.open.callCount).toBe 0
describe "when the opened path is a uri", ->
it "adds it to the project's paths as is", ->
pathToOpen = 'remote://server:7644/some/dir/path'
atom.getCurrentWindow().send 'message', 'open-locations', [{pathToOpen}]
waitsFor ->
atom.project.getPaths().length is 1
runs ->
expect(atom.project.getPaths()[0]).toBe pathToOpen

View File

@@ -522,9 +522,8 @@ class AtomApplication
new AtomWindow({bootstrapScript, @resourcePath, exitWhenDone, isSpec, specDirectory, devMode})
locationForPathToOpen: (pathToOpen) ->
{protocol} = url.parse(pathToOpen)
return {pathToOpen} if protocol?
return {pathToOpen} unless pathToOpen
return {pathToOpen} if url.parse(pathToOpen).protocol?
return {pathToOpen} if fs.existsSync(pathToOpen)
pathToOpen = pathToOpen.replace(/[:\s]+$/, '')

View File

@@ -24,9 +24,9 @@ class DefaultDirectoryProvider
# TODO: Stop normalizing the path in pathwatcher's Directory.
directory = new Directory(directoryPath)
if (url.parse(directoryPath).protocol)
if url.parse(directoryPath).protocol
directory.path = directoryPath
if (fs.isCaseInsensitive())
if fs.isCaseInsensitive()
directory.lowerCasePath = directoryPath.toLowerCase()
directory