mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Use fs.resolveOnLoadPath() instead of require.resolve()
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
RootView = require 'root-view'
|
||||
{$$} = require 'space-pen'
|
||||
fs = require 'fs-utils'
|
||||
|
||||
describe "the `atom` global", ->
|
||||
beforeEach ->
|
||||
@@ -10,7 +11,7 @@ describe "the `atom` global", ->
|
||||
|
||||
beforeEach ->
|
||||
extension = require "package-with-module"
|
||||
stylesheetPath = require.resolve("fixtures/packages/package-with-module/stylesheets/styles.css")
|
||||
stylesheetPath = fs.resolveOnLoadPath("fixtures/packages/package-with-module/stylesheets/styles.css")
|
||||
|
||||
afterEach ->
|
||||
removeStylesheet(stylesheetPath)
|
||||
@@ -57,7 +58,7 @@ describe "the `atom` global", ->
|
||||
expect(keymap.bindingsForElement(element3)['ctrl-y']).toBeUndefined()
|
||||
|
||||
it "loads stylesheets associated with the package", ->
|
||||
stylesheetPath = require.resolve("fixtures/packages/package-with-module/stylesheets/styles.css")
|
||||
stylesheetPath = fs.resolveOnLoadPath("fixtures/packages/package-with-module/stylesheets/styles.css")
|
||||
expect(stylesheetElementForId(stylesheetPath).length).toBe 0
|
||||
window.loadPackage("package-with-module")
|
||||
expect(stylesheetElementForId(stylesheetPath).length).toBe 1
|
||||
|
||||
@@ -5,7 +5,7 @@ describe "Directory", ->
|
||||
directory = null
|
||||
|
||||
beforeEach ->
|
||||
directory = new Directory(require.resolve('fixtures'))
|
||||
directory = new Directory(fs.resolveOnLoadPath('fixtures'))
|
||||
|
||||
afterEach ->
|
||||
directory.off()
|
||||
@@ -14,7 +14,7 @@ describe "Directory", ->
|
||||
temporaryFilePath = null
|
||||
|
||||
beforeEach ->
|
||||
temporaryFilePath = fs.join(require.resolve('fixtures'), 'temporary')
|
||||
temporaryFilePath = fs.join(fs.resolveOnLoadPath('fixtures'), 'temporary')
|
||||
fs.remove(temporaryFilePath) if fs.exists(temporaryFilePath)
|
||||
|
||||
afterEach ->
|
||||
@@ -64,4 +64,3 @@ describe "Directory", ->
|
||||
runs -> fs.remove(temporaryFilePath)
|
||||
waits 20
|
||||
runs -> expect(changeHandler.callCount).toBe 0
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ describe 'File', ->
|
||||
[path, file] = []
|
||||
|
||||
beforeEach ->
|
||||
path = fs.join(require.resolve('fixtures'), "atom-file-test.txt") # Don't put in /tmp because /tmp symlinks to /private/tmp and screws up the rename test
|
||||
path = fs.join(fs.resolveOnLoadPath('fixtures'), "atom-file-test.txt") # Don't put in /tmp because /tmp symlinks to /private/tmp and screws up the rename test
|
||||
fs.remove(path) if fs.exists(path)
|
||||
fs.write(path, "this is old!")
|
||||
file = new File(path)
|
||||
|
||||
@@ -21,39 +21,39 @@ describe "Git", ->
|
||||
|
||||
describe ".getPath()", ->
|
||||
it "returns the repository path for a .git directory path", ->
|
||||
repo = new Git(require.resolve('fixtures/git/master.git/HEAD'))
|
||||
expect(repo.getPath()).toBe require.resolve('fixtures/git/master.git')
|
||||
repo = new Git(fs.resolveOnLoadPath('fixtures/git/master.git/HEAD'))
|
||||
expect(repo.getPath()).toBe fs.resolveOnLoadPath('fixtures/git/master.git')
|
||||
|
||||
it "returns the repository path for a repository path", ->
|
||||
repo = new Git(require.resolve('fixtures/git/master.git'))
|
||||
expect(repo.getPath()).toBe require.resolve('fixtures/git/master.git')
|
||||
repo = new Git(fs.resolveOnLoadPath('fixtures/git/master.git'))
|
||||
expect(repo.getPath()).toBe fs.resolveOnLoadPath('fixtures/git/master.git')
|
||||
|
||||
describe ".getHead()", ->
|
||||
it "returns a branch name for a non-empty repository", ->
|
||||
repo = new Git(require.resolve('fixtures/git/master.git'))
|
||||
repo = new Git(fs.resolveOnLoadPath('fixtures/git/master.git'))
|
||||
expect(repo.getHead()).toBe 'refs/heads/master'
|
||||
|
||||
describe ".getShortHead()", ->
|
||||
it "returns a branch name for a non-empty repository", ->
|
||||
repo = new Git(require.resolve('fixtures/git/master.git'))
|
||||
repo = new Git(fs.resolveOnLoadPath('fixtures/git/master.git'))
|
||||
expect(repo.getShortHead()).toBe 'master'
|
||||
|
||||
describe ".isPathIgnored(path)", ->
|
||||
it "returns true for an ignored path", ->
|
||||
repo = new Git(require.resolve('fixtures/git/ignore.git'))
|
||||
repo = new Git(fs.resolveOnLoadPath('fixtures/git/ignore.git'))
|
||||
expect(repo.isPathIgnored('a.txt')).toBeTruthy()
|
||||
|
||||
it "returns false for a non-ignored path", ->
|
||||
repo = new Git(require.resolve('fixtures/git/ignore.git'))
|
||||
repo = new Git(fs.resolveOnLoadPath('fixtures/git/ignore.git'))
|
||||
expect(repo.isPathIgnored('b.txt')).toBeFalsy()
|
||||
|
||||
describe ".isPathModified(path)", ->
|
||||
[repo, path, newPath, originalPathText] = []
|
||||
|
||||
beforeEach ->
|
||||
repo = new Git(require.resolve('fixtures/git/working-dir'))
|
||||
path = require.resolve('fixtures/git/working-dir/file.txt')
|
||||
newPath = fs.join(require.resolve('fixtures/git/working-dir'), 'new-path.txt')
|
||||
repo = new Git(fs.resolveOnLoadPath('fixtures/git/working-dir'))
|
||||
path = fs.resolveOnLoadPath('fixtures/git/working-dir/file.txt')
|
||||
newPath = fs.join(fs.resolveOnLoadPath('fixtures/git/working-dir'), 'new-path.txt')
|
||||
originalPathText = fs.read(path)
|
||||
|
||||
afterEach ->
|
||||
@@ -79,9 +79,9 @@ describe "Git", ->
|
||||
[path, newPath] = []
|
||||
|
||||
beforeEach ->
|
||||
repo = new Git(require.resolve('fixtures/git/working-dir'))
|
||||
path = require.resolve('fixtures/git/working-dir/file.txt')
|
||||
newPath = fs.join(require.resolve('fixtures/git/working-dir'), 'new-path.txt')
|
||||
repo = new Git(fs.resolveOnLoadPath('fixtures/git/working-dir'))
|
||||
path = fs.resolveOnLoadPath('fixtures/git/working-dir/file.txt')
|
||||
newPath = fs.join(fs.resolveOnLoadPath('fixtures/git/working-dir'), 'new-path.txt')
|
||||
fs.write(newPath, "i'm new here")
|
||||
|
||||
afterEach ->
|
||||
@@ -98,10 +98,10 @@ describe "Git", ->
|
||||
[path1, path2, originalPath1Text, originalPath2Text] = []
|
||||
|
||||
beforeEach ->
|
||||
repo = new Git(require.resolve('fixtures/git/working-dir'))
|
||||
path1 = require.resolve('fixtures/git/working-dir/file.txt')
|
||||
repo = new Git(fs.resolveOnLoadPath('fixtures/git/working-dir'))
|
||||
path1 = fs.resolveOnLoadPath('fixtures/git/working-dir/file.txt')
|
||||
originalPath1Text = fs.read(path1)
|
||||
path2 = require.resolve('fixtures/git/working-dir/other.txt')
|
||||
path2 = fs.resolveOnLoadPath('fixtures/git/working-dir/other.txt')
|
||||
originalPath2Text = fs.read(path2)
|
||||
|
||||
afterEach ->
|
||||
@@ -141,7 +141,7 @@ describe "Git", ->
|
||||
|
||||
describe ".destroy()", ->
|
||||
it "throws an exception when any method is called after it is called", ->
|
||||
repo = new Git(require.resolve('fixtures/git/master.git/HEAD'))
|
||||
repo = new Git(fs.resolveOnLoadPath('fixtures/git/master.git/HEAD'))
|
||||
repo.destroy()
|
||||
expect(-> repo.getHead()).toThrow()
|
||||
|
||||
@@ -149,8 +149,8 @@ describe "Git", ->
|
||||
[path, originalPathText] = []
|
||||
|
||||
beforeEach ->
|
||||
repo = new Git(require.resolve('fixtures/git/working-dir'))
|
||||
path = require.resolve('fixtures/git/working-dir/file.txt')
|
||||
repo = new Git(fs.resolveOnLoadPath('fixtures/git/working-dir'))
|
||||
path = fs.resolveOnLoadPath('fixtures/git/working-dir/file.txt')
|
||||
originalPathText = fs.read(path)
|
||||
|
||||
afterEach ->
|
||||
@@ -165,8 +165,8 @@ describe "Git", ->
|
||||
[path, originalPathText] = []
|
||||
|
||||
beforeEach ->
|
||||
repo = new Git(require.resolve('fixtures/git/working-dir'))
|
||||
path = require.resolve('fixtures/git/working-dir/file.txt')
|
||||
repo = new Git(fs.resolveOnLoadPath('fixtures/git/working-dir'))
|
||||
path = fs.resolveOnLoadPath('fixtures/git/working-dir/file.txt')
|
||||
originalPathText = fs.read(path)
|
||||
|
||||
afterEach ->
|
||||
@@ -188,7 +188,7 @@ describe "Git", ->
|
||||
[newPath, modifiedPath, cleanPath, originalModifiedPathText] = []
|
||||
|
||||
beforeEach ->
|
||||
repo = new Git(require.resolve('fixtures/git/working-dir'))
|
||||
repo = new Git(fs.resolveOnLoadPath('fixtures/git/working-dir'))
|
||||
modifiedPath = project.resolve('git/working-dir/file.txt')
|
||||
originalModifiedPathText = fs.read(modifiedPath)
|
||||
newPath = project.resolve('git/working-dir/untracked.txt')
|
||||
|
||||
@@ -34,7 +34,7 @@ describe "Project", ->
|
||||
describe ".buildEditSession(path)", ->
|
||||
[absolutePath, newBufferHandler, newEditSessionHandler] = []
|
||||
beforeEach ->
|
||||
absolutePath = require.resolve('fixtures/dir/a')
|
||||
absolutePath = fs.resolveOnLoadPath('fixtures/dir/a')
|
||||
newBufferHandler = jasmine.createSpy('newBufferHandler')
|
||||
project.on 'buffer-created', newBufferHandler
|
||||
newEditSessionHandler = jasmine.createSpy('newEditSessionHandler')
|
||||
@@ -86,14 +86,14 @@ describe "Project", ->
|
||||
|
||||
describe ".resolve(path)", ->
|
||||
it "returns an absolute path based on the project's root", ->
|
||||
absolutePath = require.resolve('fixtures/dir/a')
|
||||
absolutePath = fs.resolveOnLoadPath('fixtures/dir/a')
|
||||
expect(project.resolve('a')).toBe absolutePath
|
||||
expect(project.resolve(absolutePath + '/../a')).toBe absolutePath
|
||||
expect(project.resolve('a/../a')).toBe absolutePath
|
||||
|
||||
describe ".relativize(path)", ->
|
||||
it "returns an relative path based on the project's root", ->
|
||||
absolutePath = require.resolve('fixtures/dir')
|
||||
absolutePath = fs.resolveOnLoadPath('fixtures/dir')
|
||||
expect(project.relativize(fs.join(absolutePath, "b"))).toBe "b"
|
||||
expect(project.relativize(fs.join(absolutePath, "b/file.coffee"))).toBe "b/file.coffee"
|
||||
expect(project.relativize(fs.join(absolutePath, "file.coffee"))).toBe "file.coffee"
|
||||
@@ -101,15 +101,15 @@ describe "Project", ->
|
||||
describe ".setPath(path)", ->
|
||||
describe "when path is a file", ->
|
||||
it "sets its path to the files parent directory and updates the root directory", ->
|
||||
project.setPath(require.resolve('fixtures/dir/a'))
|
||||
expect(project.getPath()).toEqual require.resolve('fixtures/dir')
|
||||
expect(project.getRootDirectory().path).toEqual require.resolve('fixtures/dir')
|
||||
project.setPath(fs.resolveOnLoadPath('fixtures/dir/a'))
|
||||
expect(project.getPath()).toEqual fs.resolveOnLoadPath('fixtures/dir')
|
||||
expect(project.getRootDirectory().path).toEqual fs.resolveOnLoadPath('fixtures/dir')
|
||||
|
||||
describe "when path is a directory", ->
|
||||
it "sets its path to the directory and updates the root directory", ->
|
||||
project.setPath(require.resolve('fixtures/dir/a-dir'))
|
||||
expect(project.getPath()).toEqual require.resolve('fixtures/dir/a-dir')
|
||||
expect(project.getRootDirectory().path).toEqual require.resolve('fixtures/dir/a-dir')
|
||||
project.setPath(fs.resolveOnLoadPath('fixtures/dir/a-dir'))
|
||||
expect(project.getPath()).toEqual fs.resolveOnLoadPath('fixtures/dir/a-dir')
|
||||
expect(project.getRootDirectory().path).toEqual fs.resolveOnLoadPath('fixtures/dir/a-dir')
|
||||
|
||||
describe "when path is null", ->
|
||||
it "sets its path and root directory to null", ->
|
||||
@@ -140,19 +140,19 @@ describe "Project", ->
|
||||
describe "when config.core.hideGitIgnoredFiles is true", ->
|
||||
it "ignores files that are present in .gitignore if the project is a git repo", ->
|
||||
config.set "core.hideGitIgnoredFiles", true
|
||||
project.setPath(require.resolve('fixtures/git/working-dir'))
|
||||
project.setPath(fs.resolveOnLoadPath('fixtures/git/working-dir'))
|
||||
paths = null
|
||||
waitsForPromise ->
|
||||
project.getFilePaths().done (foundPaths) -> paths = foundPaths
|
||||
|
||||
runs ->
|
||||
runs ->
|
||||
expect(paths).not.toContain('ignored.txt')
|
||||
|
||||
describe "ignored file name", ->
|
||||
ignoredFile = null
|
||||
|
||||
beforeEach ->
|
||||
ignoredFile = fs.join(require.resolve('fixtures/dir'), 'ignored.txt')
|
||||
ignoredFile = fs.join(fs.resolveOnLoadPath('fixtures/dir'), 'ignored.txt')
|
||||
fs.write(ignoredFile, "")
|
||||
|
||||
afterEach ->
|
||||
@@ -172,7 +172,7 @@ describe "Project", ->
|
||||
ignoredFile = null
|
||||
|
||||
beforeEach ->
|
||||
ignoredFile = fs.join(require.resolve('fixtures/dir'), 'ignored/ignored.txt')
|
||||
ignoredFile = fs.join(fs.resolveOnLoadPath('fixtures/dir'), 'ignored/ignored.txt')
|
||||
fs.write(ignoredFile, "")
|
||||
|
||||
afterEach ->
|
||||
@@ -222,7 +222,7 @@ describe "Project", ->
|
||||
range: [[2, 6], [2, 11]]
|
||||
|
||||
it "works on evil filenames", ->
|
||||
project.setPath(require.resolve('fixtures/evil-files'))
|
||||
project.setPath(fs.resolveOnLoadPath('fixtures/evil-files'))
|
||||
paths = []
|
||||
matches = []
|
||||
waitsForPromise ->
|
||||
@@ -246,7 +246,7 @@ describe "Project", ->
|
||||
project.scan /a+/, iterator
|
||||
|
||||
stdout = BufferedProcess.prototype.bufferStream.argsForCall[0][1]
|
||||
stdout ":#{require.resolve('fixtures/dir/a')}\n"
|
||||
stdout ":#{fs.resolveOnLoadPath('fixtures/dir/a')}\n"
|
||||
stdout "1;0 3:aaa bbb\n2;3 2:cc aa cc\n"
|
||||
|
||||
expect(iterator.argsForCall[0][0]).toEqual
|
||||
|
||||
@@ -223,7 +223,7 @@ describe "RootView", ->
|
||||
it "creates an edit session for the given path as an item on a new pane, and focuses the pane", ->
|
||||
editSession = rootView.open('b')
|
||||
expect(rootView.getActivePane().activeItem).toBe editSession
|
||||
expect(editSession.getPath()).toBe require.resolve('fixtures/dir/b')
|
||||
expect(editSession.getPath()).toBe fs.resolveOnLoadPath('fixtures/dir/b')
|
||||
expect(rootView.getActivePane().focus).toHaveBeenCalled()
|
||||
|
||||
describe "when the changeFocus option is false", ->
|
||||
|
||||
@@ -46,7 +46,7 @@ describe 'Buffer', ->
|
||||
[path, newPath, bufferToChange, eventHandler] = []
|
||||
|
||||
beforeEach ->
|
||||
path = fs.join(require.resolve("fixtures/"), "atom-manipulate-me")
|
||||
path = fs.join(fs.resolveOnLoadPath("fixtures"), "atom-manipulate-me")
|
||||
newPath = "#{path}-i-moved"
|
||||
fs.write(path, "")
|
||||
bufferToChange = new Buffer(path)
|
||||
|
||||
@@ -7,7 +7,7 @@ describe "TextMateTheme", ->
|
||||
[theme, themePath] = []
|
||||
|
||||
beforeEach ->
|
||||
themePath = require.resolve(fs.join('fixtures', 'test.tmTheme'))
|
||||
themePath = fs.resolveOnLoadPath(fs.join('fixtures', 'test.tmTheme'))
|
||||
theme = Theme.load(themePath)
|
||||
|
||||
afterEach ->
|
||||
|
||||
@@ -15,7 +15,7 @@ describe "@load(name)", ->
|
||||
it "applies the theme's stylesheet to the current window", ->
|
||||
expect($(".editor").css("background-color")).not.toBe("rgb(20, 20, 20)")
|
||||
|
||||
themePath = require.resolve(fs.join('fixtures', 'test.tmTheme'))
|
||||
themePath = fs.resolveOnLoadPath(fs.join('fixtures', 'test.tmTheme'))
|
||||
theme = Theme.load(themePath)
|
||||
expect($(".editor").css("background-color")).toBe("rgb(20, 20, 20)")
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ describe "fs", ->
|
||||
expect(-> fs.read(require.resolve("fixtures/binary-file.png"))).not.toThrow()
|
||||
|
||||
describe ".isFile(path)", ->
|
||||
fixturesDir = require.resolve('fixtures')
|
||||
fixturesDir = fs.resolveOnLoadPath('fixtures')
|
||||
|
||||
it "returns true with a file path", ->
|
||||
expect(fs.isFile(fs.join(fixturesDir, 'sample.js'))).toBe true
|
||||
@@ -24,7 +24,7 @@ describe "fs", ->
|
||||
describe ".directory(path)", ->
|
||||
describe "when called with a file path", ->
|
||||
it "returns the path to the directory", ->
|
||||
expect(fs.directory(require.resolve('fixtures/dir/a'))).toBe require.resolve('fixtures/dir')
|
||||
expect(fs.directory(fs.resolveOnLoadPath('fixtures/dir/a'))).toBe fs.resolveOnLoadPath('fixtures/dir')
|
||||
|
||||
describe "when called with a directory path", ->
|
||||
it "return the path it was given", ->
|
||||
@@ -42,10 +42,10 @@ describe "fs", ->
|
||||
|
||||
describe ".exists(path)", ->
|
||||
it "returns true when path exsits", ->
|
||||
expect(fs.exists(require.resolve('fixtures'))).toBe true
|
||||
expect(fs.exists(fs.resolveOnLoadPath('fixtures'))).toBe true
|
||||
|
||||
it "returns false when path doesn't exsit", ->
|
||||
expect(fs.exists(require.resolve("fixtures") + "/-nope-does-not-exist")).toBe false
|
||||
expect(fs.exists(fs.resolveOnLoadPath("fixtures") + "/-nope-does-not-exist")).toBe false
|
||||
expect(fs.exists("")).toBe false
|
||||
expect(fs.exists(null)).toBe false
|
||||
|
||||
@@ -81,7 +81,7 @@ describe "fs", ->
|
||||
fixturesDir = null
|
||||
|
||||
beforeEach ->
|
||||
fixturesDir = require.resolve('fixtures')
|
||||
fixturesDir = fs.resolveOnLoadPath('fixtures')
|
||||
|
||||
it "calls fn for every path in the tree at the given path", ->
|
||||
paths = []
|
||||
@@ -124,4 +124,4 @@ describe "fs", ->
|
||||
describe ".list(path, extensions)", ->
|
||||
it "returns the paths with the specified extensions", ->
|
||||
path = require.resolve('fixtures/css.css')
|
||||
expect(fs.list(require.resolve('fixtures'), ['.css'])).toEqual [path]
|
||||
expect(fs.list(fs.resolveOnLoadPath('fixtures'), ['.css'])).toEqual [path]
|
||||
|
||||
@@ -62,7 +62,10 @@ class AtomPackage extends Package
|
||||
activatePackageMain: ->
|
||||
mainPath = @path
|
||||
mainPath = fs.join(mainPath, @metadata.main) if @metadata.main
|
||||
mainPath = require.resolve(mainPath)
|
||||
try
|
||||
mainPath = require.resolve(mainPath)
|
||||
catch e
|
||||
return
|
||||
if fs.isFile(mainPath)
|
||||
@packageMain = require(mainPath)
|
||||
config.setDefaults(@name, @packageMain.configDefaults)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
fs = require 'fs-utils'
|
||||
TextMatePackage = require 'text-mate-package'
|
||||
|
||||
describe "GitHub Flavored Markdown grammar", ->
|
||||
@@ -5,7 +6,7 @@ describe "GitHub Flavored Markdown grammar", ->
|
||||
|
||||
beforeEach ->
|
||||
spyOn(syntax, "addGrammar")
|
||||
pack = new TextMatePackage(require.resolve("gfm.tmbundle"))
|
||||
pack = new TextMatePackage(fs.resolveOnLoadPath("gfm.tmbundle"))
|
||||
pack.load()
|
||||
grammar = pack.grammars[0]
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class PackageGeneratorView extends View
|
||||
true
|
||||
|
||||
createPackageFiles: ->
|
||||
templatePath = require.resolve(fs.join("package-generator", "template"))
|
||||
templatePath = fs.resolveOnLoadPath(fs.join("package-generator", "template"))
|
||||
packageName = fs.base(@getPackagePath())
|
||||
|
||||
for path in fs.listTree(templatePath)
|
||||
|
||||
@@ -112,7 +112,7 @@ describe "StatusBar", ->
|
||||
|
||||
it "displays the current branch for files in repositories", ->
|
||||
path = require.resolve('fixtures/git/master.git/HEAD')
|
||||
project.setPath(require.resolve('fixtures/git/master.git'))
|
||||
project.setPath(fs.resolveOnLoadPath('fixtures/git/master.git'))
|
||||
rootView.open(path)
|
||||
expect(statusBar.branchArea).toBeVisible()
|
||||
expect(statusBar.branchLabel.text()).toBe 'master'
|
||||
@@ -128,7 +128,7 @@ describe "StatusBar", ->
|
||||
|
||||
beforeEach ->
|
||||
path = require.resolve('fixtures/git/working-dir/file.txt')
|
||||
newPath = fs.join(require.resolve('fixtures/git/working-dir'), 'new.txt')
|
||||
newPath = fs.join(fs.resolveOnLoadPath('fixtures/git/working-dir'), 'new.txt')
|
||||
fs.write(newPath, "I'm new here")
|
||||
git.getPathStatus(path)
|
||||
git.getPathStatus(newPath)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
fs = require 'fs-utils'
|
||||
TextMatePackage = require 'text-mate-package'
|
||||
|
||||
describe "TOML grammar", ->
|
||||
@@ -5,7 +6,7 @@ describe "TOML grammar", ->
|
||||
|
||||
beforeEach ->
|
||||
spyOn(syntax, "addGrammar")
|
||||
pack = new TextMatePackage(require.resolve("toml.tmbundle"))
|
||||
pack = new TextMatePackage(fs.resolveOnLoadPath("toml.tmbundle"))
|
||||
pack.load()
|
||||
grammar = pack.grammars[0]
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ describe "TreeView", ->
|
||||
it "creates a root directory view but does not attach to the root view", ->
|
||||
rootView.getActivePaneItem().saveAs("/tmp/test.txt")
|
||||
expect(treeView.hasParent()).toBeFalsy()
|
||||
expect(treeView.root.getPath()).toBe require.resolve('/tmp')
|
||||
expect(treeView.root.getPath()).toBe '/tmp'
|
||||
expect(treeView.root.parent()).toMatchSelector(".tree-view")
|
||||
|
||||
describe "when the root view is opened to a file path", ->
|
||||
@@ -266,20 +266,20 @@ describe "TreeView", ->
|
||||
|
||||
sampleJs.trigger clickEvent(originalEvent: { detail: 1 })
|
||||
expect(sampleJs).toHaveClass 'selected'
|
||||
expect(rootView.getActiveView().getPath()).toBe require.resolve('fixtures/tree-view/tree-view.js')
|
||||
expect(rootView.getActiveView().getPath()).toBe fs.resolveOnLoadPath('fixtures/tree-view/tree-view.js')
|
||||
expect(rootView.getActiveView().isFocused).toBeFalsy()
|
||||
|
||||
sampleTxt.trigger clickEvent(originalEvent: { detail: 1 })
|
||||
expect(sampleTxt).toHaveClass 'selected'
|
||||
expect(treeView.find('.selected').length).toBe 1
|
||||
expect(rootView.getActiveView().getPath()).toBe require.resolve('fixtures/tree-view/tree-view.txt')
|
||||
expect(rootView.getActiveView().getPath()).toBe fs.resolveOnLoadPath('fixtures/tree-view/tree-view.txt')
|
||||
expect(rootView.getActiveView().isFocused).toBeFalsy()
|
||||
|
||||
describe "when a file is double-clicked", ->
|
||||
it "selects the file and opens it in the active editor on the first click, then changes focus to the active editor on the second", ->
|
||||
sampleJs.trigger clickEvent(originalEvent: { detail: 1 })
|
||||
expect(sampleJs).toHaveClass 'selected'
|
||||
expect(rootView.getActiveView().getPath()).toBe require.resolve('fixtures/tree-view/tree-view.js')
|
||||
expect(rootView.getActiveView().getPath()).toBe fs.resolveOnLoadPath('fixtures/tree-view/tree-view.js')
|
||||
expect(rootView.getActiveView().isFocused).toBeFalsy()
|
||||
|
||||
sampleJs.trigger clickEvent(originalEvent: { detail: 2 })
|
||||
@@ -304,7 +304,7 @@ describe "TreeView", ->
|
||||
describe "when a new file is opened in the active editor", ->
|
||||
it "selects the file in the tree view if the file's entry visible", ->
|
||||
sampleJs.click()
|
||||
rootView.open(require.resolve('fixtures/tree-view/tree-view.txt'))
|
||||
rootView.open(fs.resolveOnLoadPath('fixtures/tree-view/tree-view.txt'))
|
||||
|
||||
expect(sampleTxt).toHaveClass 'selected'
|
||||
expect(treeView.find('.selected').length).toBe 1
|
||||
@@ -568,7 +568,7 @@ describe "TreeView", ->
|
||||
it "opens the file in the editor and focuses it", ->
|
||||
treeView.root.find('.file:contains(tree-view.js)').click()
|
||||
treeView.root.trigger 'tree-view:open-selected-entry'
|
||||
expect(rootView.getActiveView().getPath()).toBe require.resolve('fixtures/tree-view/tree-view.js')
|
||||
expect(rootView.getActiveView().getPath()).toBe fs.resolveOnLoadPath('fixtures/tree-view/tree-view.js')
|
||||
expect(rootView.getActiveView().isFocused).toBeTruthy()
|
||||
|
||||
describe "when a directory is selected", ->
|
||||
@@ -875,7 +875,7 @@ describe "TreeView", ->
|
||||
temporaryFilePath = null
|
||||
|
||||
beforeEach ->
|
||||
temporaryFilePath = fs.join(require.resolve('fixtures/tree-view'), 'temporary')
|
||||
temporaryFilePath = fs.join(fs.resolveOnLoadPath('fixtures/tree-view'), 'temporary')
|
||||
if fs.exists(temporaryFilePath)
|
||||
fs.remove(temporaryFilePath)
|
||||
waits(20)
|
||||
@@ -907,7 +907,7 @@ describe "TreeView", ->
|
||||
[ignoreFile] = []
|
||||
|
||||
beforeEach ->
|
||||
ignoreFile = fs.join(require.resolve('fixtures/tree-view'), '.gitignore')
|
||||
ignoreFile = fs.join(fs.resolveOnLoadPath('fixtures/tree-view'), '.gitignore')
|
||||
fs.write(ignoreFile, 'tree-view.js')
|
||||
config.set "core.hideGitIgnoredFiles", false
|
||||
|
||||
@@ -930,15 +930,15 @@ describe "TreeView", ->
|
||||
|
||||
beforeEach ->
|
||||
config.set "core.hideGitIgnoredFiles", false
|
||||
ignoreFile = fs.join(require.resolve('fixtures/tree-view'), '.gitignore')
|
||||
ignoreFile = fs.join(fs.resolveOnLoadPath('fixtures/tree-view'), '.gitignore')
|
||||
fs.write(ignoreFile, 'tree-view.js')
|
||||
git.getPathStatus(ignoreFile)
|
||||
|
||||
newFile = fs.join(require.resolve('fixtures/tree-view/dir2'), 'new2')
|
||||
newFile = fs.join(fs.resolveOnLoadPath('fixtures/tree-view/dir2'), 'new2')
|
||||
fs.write(newFile, '')
|
||||
git.getPathStatus(newFile)
|
||||
|
||||
modifiedFile = fs.join(require.resolve('fixtures/tree-view/dir1'), 'file1')
|
||||
modifiedFile = fs.join(fs.resolveOnLoadPath('fixtures/tree-view/dir1'), 'file1')
|
||||
originalFileContent = fs.read(modifiedFile)
|
||||
fs.write modifiedFile, 'ch ch changes'
|
||||
git.getPathStatus(modifiedFile)
|
||||
|
||||
Reference in New Issue
Block a user