Fix tests + add integration test

This commit is contained in:
Mostafa Eweda 2015-05-19 19:04:54 -07:00
parent 638d8cc13f
commit e7064bfc9d
3 changed files with 25 additions and 8 deletions

View File

@ -227,3 +227,13 @@ describe "Starting Atom", ->
[tempDirPath]
[otherTempDirPath]
].sort()
describe "opening a remote directory", ->
it "opens the parent directory and creates an empty text editor", ->
remoteDirectory = 'remote://server:3437/some/directory/path'
runAtom [remoteDirectory], {ATOM_HOME: atomHome}, (client) ->
client
.waitForWindowCount(1, 1000)
.waitForExist("atom-workspace", 5000)
.treeViewRootDirectories()
.then ({value}) -> expect(value).toEqual([remoteDirectory])

View File

@ -5,6 +5,7 @@ app = require 'app'
fs = require 'fs-plus'
path = require 'path'
yargs = require 'yargs'
url = require 'url'
nslog = require 'nslog'
console.log = nslog
@ -45,9 +46,11 @@ start = ->
cwd = args.executedFrom?.toString() or process.cwd()
args.pathsToOpen = args.pathsToOpen.map (pathToOpen) ->
pathToOpen = fs.normalize(pathToOpen)
if cwd
path.resolve(cwd, pathToOpen)
normalizedPath = fs.normalize(pathToOpen)
if url.parse(pathToOpen || '').protocol?
pathToOpen
else if cwd
path.resolve(cwd, normalizedPath)
else
path.resolve(pathToOpen)

View File

@ -15,14 +15,18 @@ class DefaultDirectoryProvider
# * {Directory} if the given URI is compatible with this provider.
# * `null` if the given URI is not compatibile with this provider.
directoryForURISync: (uri) ->
directoryPath = if not fs.isDirectorySync(uri) and fs.isDirectorySync(path.dirname(uri))
path.normalize(path.dirname(uri))
else
normalizedPath = path.normalize(uri);
{protocol} = url.parse(uri || '')
directoryPath = if protocol?
uri
else if not fs.isDirectorySync(normalizedPath) and fs.isDirectorySync(path.dirname(normalizedPath))
path.dirname(normalizedPath)
else
normalizedPath
# TODO: Stop normalizing the path in pathwatcher Directory.
# TODO: Stop normalizing the path in pathwatcher's Directory.
directory = new Directory(directoryPath)
if url.parse(directoryPath).protocol?
if protocol?
directory.path = directoryPath
if fs.isCaseInsensitive()
directory.lowerCasePath = directoryPath.toLowerCase()