Add atom prefix to rootView and project references

This commit is contained in:
Kevin Sawicki 2013-11-20 15:35:49 -08:00
parent 99480901e2
commit d0b380e535
17 changed files with 290 additions and 290 deletions

View File

@ -6,7 +6,7 @@ describe "DisplayBuffer", ->
beforeEach ->
tabLength = 2
atom.packages.activatePackage('language-javascript', sync: true)
buffer = project.bufferForPathSync('sample.js')
buffer = atom.project.bufferForPathSync('sample.js')
displayBuffer = new DisplayBuffer({buffer, tabLength})
changeHandler = jasmine.createSpy 'changeHandler'
displayBuffer.on 'changed', changeHandler
@ -154,7 +154,7 @@ describe "DisplayBuffer", ->
describe "when a newline is inserted, deleted, and re-inserted at the end of a wrapped line (regression)", ->
it "correctly renders the original wrapped line", ->
buffer = project.buildBufferSync(null, '')
buffer = atom.project.buildBufferSync(null, '')
displayBuffer = new DisplayBuffer({buffer, tabLength, editorWidthInChars: 30, softWrap: true})
buffer.insert([0, 0], "the quick brown fox jumps over the lazy dog.")
@ -206,7 +206,7 @@ describe "DisplayBuffer", ->
beforeEach ->
displayBuffer.destroy()
buffer.release()
buffer = project.bufferForPathSync('two-hundred.txt')
buffer = atom.project.bufferForPathSync('two-hundred.txt')
displayBuffer = new DisplayBuffer({buffer, tabLength})
displayBuffer.on 'changed', changeHandler

View File

@ -8,7 +8,7 @@ describe "Editor", ->
describe "with an initial line option", ->
beforeEach ->
editor = project.openSync('sample.js', initialLine: 2)
editor = atom.project.openSync('sample.js', initialLine: 2)
buffer = editor.buffer
it "opens the file and positions the cursor on line 2", ->
@ -17,7 +17,7 @@ describe "Editor", ->
describe "with default options", ->
beforeEach ->
atom.packages.activatePackage('language-javascript', sync: true)
editor = project.openSync('sample.js', autoIndent: false)
editor = atom.project.openSync('sample.js', autoIndent: false)
buffer = editor.buffer
lineLengths = buffer.getLines().map (line) -> line.length
@ -60,7 +60,7 @@ describe "Editor", ->
atom.config.set('editor.tabLength', 4)
atom.config.set('editor.softWrap', true)
atom.config.set('editor.softTabs', false)
editor1 = project.openSync('a')
editor1 = atom.project.openSync('a')
expect(editor1.getTabLength()).toBe 4
expect(editor1.getSoftWrap()).toBe true
expect(editor1.getSoftTabs()).toBe false
@ -68,7 +68,7 @@ describe "Editor", ->
atom.config.set('editor.tabLength', 100)
atom.config.set('editor.softWrap', false)
atom.config.set('editor.softTabs', true)
editor2 = project.openSync('b')
editor2 = atom.project.openSync('b')
expect(editor2.getTabLength()).toBe 100
expect(editor2.getSoftWrap()).toBe false
expect(editor2.getSoftTabs()).toBe true
@ -1184,7 +1184,7 @@ describe "Editor", ->
expect(selection.isEmpty()).toBeTruthy()
it "does not share selections between different edit sessions for the same buffer", ->
editor2 = project.openSync('sample.js')
editor2 = atom.project.openSync('sample.js')
editor.setSelectedBufferRanges([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
editor2.setSelectedBufferRanges([[[8, 7], [6, 5]], [[4, 3], [2, 1]]])
expect(editor2.getSelectedBufferRanges()).not.toEqual editor.getSelectedBufferRanges()
@ -2036,7 +2036,7 @@ describe "Editor", ->
it "does not explode if the current language mode has no comment regex", ->
editor.destroy()
editor = project.openSync(null, autoIndent: false)
editor = atom.project.openSync(null, autoIndent: false)
editor.setSelectedBufferRange([[4, 5], [4, 5]])
editor.toggleLineCommentsInSelection()
expect(buffer.lineForRow(4)).toBe " while(items.length > 0) {"
@ -2358,13 +2358,13 @@ describe "Editor", ->
describe "soft-tabs detection", ->
it "assigns soft / hard tabs based on the contents of the buffer, or uses the default if unknown", ->
editor = project.openSync('sample.js', softTabs: false)
editor = atom.project.openSync('sample.js', softTabs: false)
expect(editor.getSoftTabs()).toBeTruthy()
editor = project.openSync('sample-with-tabs.coffee', softTabs: true)
editor = atom.project.openSync('sample-with-tabs.coffee', softTabs: true)
expect(editor.getSoftTabs()).toBeFalsy()
editor = project.openSync(null, softTabs: false)
editor = atom.project.openSync(null, softTabs: false)
expect(editor.getSoftTabs()).toBeFalsy()
describe ".indentLevelForLine(line)", ->
@ -2393,7 +2393,7 @@ describe "Editor", ->
jsGrammar = atom.syntax.selectGrammar('a.js')
atom.syntax.removeGrammar(jsGrammar)
editor = project.openSync('sample.js', autoIndent: false)
editor = atom.project.openSync('sample.js', autoIndent: false)
expect(editor.getGrammar()).toBe atom.syntax.nullGrammar
expect(editor.lineForScreenRow(0).tokens.length).toBe 1
@ -2614,7 +2614,7 @@ describe "Editor", ->
expect(editor.shouldPromptToSave()).toBeFalsy()
buffer.setText('changed')
expect(editor.shouldPromptToSave()).toBeTruthy()
editor2 = project.openSync('sample.js', autoIndent: false)
editor2 = atom.project.openSync('sample.js', autoIndent: false)
expect(editor.shouldPromptToSave()).toBeFalsy()
editor2.destroy()
expect(editor.shouldPromptToSave()).toBeTruthy()

View File

@ -12,7 +12,7 @@ describe "EditorView", ->
beforeEach ->
atom.packages.activatePackage('language-text', sync: true)
atom.packages.activatePackage('language-javascript', sync: true)
editor = project.openSync('sample.js')
editor = atom.project.openSync('sample.js')
buffer = editor.buffer
editorView = new EditorView(editor)
editorView.lineOverdraw = 2
@ -37,7 +37,7 @@ describe "EditorView", ->
cachedCharWidth
calcDimensions = ->
editorForMeasurement = new EditorView(editor: project.openSync('sample.js'))
editorForMeasurement = new EditorView(editor: atom.project.openSync('sample.js'))
editorForMeasurement.attachToDom()
cachedLineHeight = editorForMeasurement.lineHeight
cachedCharWidth = editorForMeasurement.charWidth
@ -103,7 +103,7 @@ describe "EditorView", ->
it "triggers an alert", ->
filePath = path.join(temp.dir, 'atom-changed-file.txt')
fs.writeFileSync(filePath, "")
editor = project.openSync(filePath)
editor = atom.project.openSync(filePath)
editorView.edit(editor)
editorView.insertText("now the buffer is modified")
@ -129,7 +129,7 @@ describe "EditorView", ->
[newEditSession, newBuffer] = []
beforeEach ->
newEditSession = project.openSync('two-hundred.txt')
newEditSession = atom.project.openSync('two-hundred.txt')
newBuffer = newEditSession.buffer
it "updates the rendered lines, cursors, selections, scroll position, and event subscriptions to match the given edit session", ->
@ -168,7 +168,7 @@ describe "EditorView", ->
it "triggers alert if edit session's buffer goes into conflict with changes on disk", ->
filePath = path.join(temp.dir, 'atom-changed-file.txt')
fs.writeFileSync(filePath, "")
tempEditSession = project.openSync(filePath)
tempEditSession = atom.project.openSync(filePath)
editorView.edit(tempEditSession)
tempEditSession.insertText("a buffer change")
@ -1736,7 +1736,7 @@ describe "EditorView", ->
expect(editorView.bufferPositionForScreenPosition(editorView.getCursorScreenPosition())).toEqual [3, 60]
it "does not wrap the lines of any newly assigned buffers", ->
otherEditSession = project.openSync()
otherEditSession = atom.project.openSync()
otherEditSession.buffer.setText([1..100].join(''))
editorView.edit(otherEditSession)
expect(editorView.renderedLines.find('.line').length).toBe(1)
@ -1768,7 +1768,7 @@ describe "EditorView", ->
expect(editorView.getCursorScreenPosition()).toEqual [11, 0]
it "calls .setWidthInChars() when the editor view is attached because now its dimensions are available to calculate it", ->
otherEditor = new EditorView(editor: project.openSync('sample.js'))
otherEditor = new EditorView(editor: atom.project.openSync('sample.js'))
spyOn(otherEditor, 'setWidthInChars')
otherEditor.activeEditSession.setSoftWrap(true)
@ -1894,7 +1894,7 @@ describe "EditorView", ->
describe "when the switching from an edit session for a long buffer to an edit session for a short buffer", ->
it "updates the line numbers to reflect the shorter buffer", ->
emptyEditSession = project.openSync(null)
emptyEditSession = atom.project.openSync(null)
editorView.edit(emptyEditSession)
expect(editorView.gutter.lineNumbers.find('.line-number').length).toBe 1
@ -2098,7 +2098,7 @@ describe "EditorView", ->
describe "folding", ->
beforeEach ->
editor = project.openSync('two-hundred.txt')
editor = atom.project.openSync('two-hundred.txt')
buffer = editor.buffer
editorView.edit(editor)
editorView.attachToDom()
@ -2234,7 +2234,7 @@ describe "EditorView", ->
[filePath, originalPathText] = []
beforeEach ->
filePath = project.resolve('git/working-dir/file.txt')
filePath = atom.project.resolve('git/working-dir/file.txt')
originalPathText = fs.readFileSync(filePath, 'utf8')
editorView.edit(project.openSync(filePath))
@ -2741,9 +2741,9 @@ describe "EditorView", ->
describe "when the editor view's text is changed", ->
it "redraws the editor view when it is next shown", ->
atom.rootView = new RootView
rootView.openSync('sample.js')
rootView.attachToDom()
editorView = rootView.getActiveView()
atom.rootView.openSync('sample.js')
atom.rootView.attachToDom()
editorView = atom.rootView.getActiveView()
view = $$ -> @div id: 'view', tabindex: -1, 'View'
editorView.getPane().showItem(view)
@ -2795,9 +2795,9 @@ describe "EditorView", ->
describe "when the editor view is removed", ->
it "fires a editor:will-be-removed event", ->
atom.rootView = new RootView
rootView.openSync('sample.js')
rootView.attachToDom()
editorView = rootView.getActiveView()
atom.rootView.openSync('sample.js')
atom.rootView.attachToDom()
editorView = atom.rootView.getActiveView()
willBeRemovedHandler = jasmine.createSpy('fileChange')
editorView.on 'editor:will-be-removed', willBeRemovedHandler

View File

@ -9,5 +9,5 @@ module.exports =
activate: ->
@activateCallCount++
rootView.getActiveView()?.command 'activation-event', =>
atom.rootView.getActiveView()?.command 'activation-event', =>
@activationEventCallCount++

View File

@ -182,10 +182,10 @@ describe "Git", ->
beforeEach ->
repo = new Git(path.join(__dirname, 'fixtures', 'git', 'working-dir'))
modifiedPath = project.resolve('git/working-dir/file.txt')
modifiedPath = atom.project.resolve('git/working-dir/file.txt')
originalModifiedPathText = fs.readFileSync(modifiedPath, 'utf8')
newPath = project.resolve('git/working-dir/untracked.txt')
cleanPath = project.resolve('git/working-dir/other.txt')
newPath = atom.project.resolve('git/working-dir/untracked.txt')
cleanPath = atom.project.resolve('git/working-dir/other.txt')
fs.writeFileSync(newPath, '')
afterEach ->
@ -211,7 +211,7 @@ describe "Git", ->
[originalContent, editor] = []
beforeEach ->
editor = project.openSync('sample.js')
editor = atom.project.openSync('sample.js')
originalContent = editor.getText()
afterEach ->
@ -221,7 +221,7 @@ describe "Git", ->
editor.insertNewline()
statusHandler = jasmine.createSpy('statusHandler')
project.getRepo().on 'status-changed', statusHandler
atom.project.getRepo().on 'status-changed', statusHandler
editor.save()
expect(statusHandler.callCount).toBe 1
expect(statusHandler).toHaveBeenCalledWith editor.getPath(), 256
@ -230,7 +230,7 @@ describe "Git", ->
fs.writeFileSync(editor.getPath(), 'changed')
statusHandler = jasmine.createSpy('statusHandler')
project.getRepo().on 'status-changed', statusHandler
atom.project.getRepo().on 'status-changed', statusHandler
editor.getBuffer().reload()
expect(statusHandler.callCount).toBe 1
expect(statusHandler).toHaveBeenCalledWith editor.getPath(), 256
@ -241,7 +241,7 @@ describe "Git", ->
fs.writeFileSync(editor.getPath(), 'changed')
statusHandler = jasmine.createSpy('statusHandler')
project.getRepo().on 'status-changed', statusHandler
atom.project.getRepo().on 'status-changed', statusHandler
editor.getBuffer().emit 'path-changed'
expect(statusHandler.callCount).toBe 1
expect(statusHandler).toHaveBeenCalledWith editor.getPath(), 256
@ -256,7 +256,7 @@ describe "Git", ->
project2?.destroy()
it "subscribes to all the serialized buffers in the project", ->
project.openSync('sample.js')
atom.project.openSync('sample.js')
#TODO Replace with atom.replicate().project when Atom is a telepath model
project2 = atom.replicate().get('project')
buffer = project2.getBuffers()[0]

View File

@ -160,10 +160,10 @@ describe "Keymap", ->
describe "when the event's target is the document body", ->
it "triggers the mapped event on the rootView", ->
atom.rootView = new RootView
rootView.attachToDom()
atom.rootView.attachToDom()
keymap.bindKeys 'name', 'body', 'x': 'foo'
fooHandler = jasmine.createSpy("fooHandler")
rootView.on 'foo', fooHandler
atom.rootView.on 'foo', fooHandler
result = keymap.handleKeyEvent(keydownEvent('x', target: document.body))
expect(result).toBe(false)

View File

@ -7,7 +7,7 @@ describe "LanguageMode", ->
describe "javascript", ->
beforeEach ->
atom.packages.activatePackage('language-javascript', sync: true)
editor = project.openSync('sample.js', autoIndent: false)
editor = atom.project.openSync('sample.js', autoIndent: false)
{buffer, languageMode} = editor
describe ".minIndentLevelForRowRange(startRow, endRow)", ->
@ -110,7 +110,7 @@ describe "LanguageMode", ->
describe "coffeescript", ->
beforeEach ->
atom.packages.activatePackage('language-coffee-script', sync: true)
editor = project.openSync('coffee.coffee', autoIndent: false)
editor = atom.project.openSync('coffee.coffee', autoIndent: false)
{buffer, languageMode} = editor
describe ".toggleLineCommentsForBufferRows(start, end)", ->
@ -157,7 +157,7 @@ describe "LanguageMode", ->
describe "css", ->
beforeEach ->
atom.packages.activatePackage('language-css', sync: true)
editor = project.openSync('css.css', autoIndent: false)
editor = atom.project.openSync('css.css', autoIndent: false)
{buffer, languageMode} = editor
describe ".toggleLineCommentsForBufferRows(start, end)", ->
@ -199,7 +199,7 @@ describe "LanguageMode", ->
beforeEach ->
atom.packages.activatePackage('language-less', sync: true)
atom.packages.activatePackage('language-css', sync: true)
editor = project.openSync('sample.less', autoIndent: false)
editor = atom.project.openSync('sample.less', autoIndent: false)
{buffer, languageMode} = editor
describe "when commenting lines", ->
@ -210,7 +210,7 @@ describe "LanguageMode", ->
describe "folding", ->
beforeEach ->
atom.packages.activatePackage('language-javascript', sync: true)
editor = project.openSync('sample.js', autoIndent: false)
editor = atom.project.openSync('sample.js', autoIndent: false)
{buffer, languageMode} = editor
it "maintains cursor buffer position when a folding/unfolding", ->
@ -300,7 +300,7 @@ describe "LanguageMode", ->
describe "folding with comments", ->
beforeEach ->
atom.packages.activatePackage('language-javascript', sync: true)
editor = project.openSync('sample-with-comments.js', autoIndent: false)
editor = atom.project.openSync('sample-with-comments.js', autoIndent: false)
{buffer, languageMode} = editor
describe ".unfoldAll()", ->
@ -354,7 +354,7 @@ describe "LanguageMode", ->
beforeEach ->
atom.packages.activatePackage('language-source', sync: true)
atom.packages.activatePackage('language-css', sync: true)
editor = project.openSync('css.css', autoIndent: true)
editor = atom.project.openSync('css.css', autoIndent: true)
describe "suggestedIndentForBufferRow", ->
it "does not return negative values (regression)", ->

View File

@ -111,7 +111,7 @@ describe "PaneContainer", ->
describe "when the last-closed pane item is an edit session", ->
it "reopens the edit session (regression)", ->
editor = project.openSync('sample.js')
editor = atom.project.openSync('sample.js')
pane3.showItem(editor)
pane3.destroyItem(editor)
expect(container.reopenItem()).toBeTruthy()

View File

@ -20,8 +20,8 @@ describe "Pane", ->
container = new PaneContainer
view1 = new TestView(id: 'view-1', text: 'View 1')
view2 = new TestView(id: 'view-2', text: 'View 2')
editor1 = project.openSync('sample.js')
editor2 = project.openSync('sample.txt')
editor1 = atom.project.openSync('sample.js')
editor2 = atom.project.openSync('sample.txt')
pane = new Pane(view1, editor1, view2, editor2)
container.setRoot(pane)
@ -702,8 +702,8 @@ describe "Pane", ->
projectReplica = atom.replicate().get('project')
containerState = container.serialize()
container.remove()
project.destroy()
window.project = projectReplica
atom.project.destroy()
container = atom.deserializers.deserialize(containerState)
pane = container.getRoot()
container.attachToDom()

View File

@ -8,7 +8,7 @@ BufferedProcess = require '../src/buffered-process'
describe "Project", ->
beforeEach ->
project.setPath(project.resolve('dir'))
atom.project.setPath(project.resolve('dir'))
describe "serialization", ->
deserializedProject = null
@ -17,17 +17,17 @@ describe "Project", ->
deserializedProject?.destroy()
it "destroys unretained buffers and does not include them in the serialized state", ->
project.bufferForPathSync('a')
atom.project.bufferForPathSync('a')
expect(project.getBuffers().length).toBe 1
project.getState().serializeForPersistence()
atom.project.getState().serializeForPersistence()
deserializedProject = atom.replicate().get('project')
expect(deserializedProject.getBuffers().length).toBe 0
expect(project.getBuffers().length).toBe 0
it "listens for destroyed events on deserialized buffers and removes them when they are destroyed", ->
project.openSync('a')
atom.project.openSync('a')
expect(project.getBuffers().length).toBe 1
project.getState().serializeForPersistence()
atom.project.getState().serializeForPersistence()
deserializedProject = atom.replicate().get('project')
expect(deserializedProject.getBuffers().length).toBe 1
@ -36,8 +36,8 @@ describe "Project", ->
describe "when an edit session is destroyed", ->
it "removes edit session and calls destroy on buffer (if buffer is not referenced by other edit sessions)", ->
editor = project.openSync("a")
anotherEditSession = project.openSync("a")
editor = atom.project.openSync("a")
anotherEditSession = atom.project.openSync("a")
expect(project.editors.length).toBe 2
expect(editor.buffer).toBe anotherEditSession.buffer
@ -51,18 +51,18 @@ describe "Project", ->
describe "when an edit session is saved and the project has no path", ->
it "sets the project's path to the saved file's parent directory", ->
tempFile = temp.openSync().path
project.setPath(undefined)
atom.project.setPath(undefined)
expect(project.getPath()).toBeUndefined()
editor = project.openSync()
editor = atom.project.openSync()
editor.saveAs(tempFile)
expect(project.getPath()).toBe path.dirname(tempFile)
describe "when an edit session is deserialized", ->
it "emits an 'editor-created' event and stores the edit session", ->
handler = jasmine.createSpy('editorCreatedHandler')
project.on 'editor-created', handler
atom.project.on 'editor-created', handler
editor1 = project.openSync("a")
editor1 = atom.project.openSync("a")
expect(handler.callCount).toBe 1
expect(project.getEditSessions().length).toBe 1
expect(project.getEditSessions()[0]).toBe editor1
@ -76,9 +76,9 @@ describe "Project", ->
describe "when an edit session is copied", ->
it "emits an 'editor-created' event and stores the edit session", ->
handler = jasmine.createSpy('editorCreatedHandler')
project.on 'editor-created', handler
atom.project.on 'editor-created', handler
editor1 = project.openSync("a")
editor1 = atom.project.openSync("a")
expect(handler.callCount).toBe 1
expect(project.getEditSessions().length).toBe 1
expect(project.getEditSessions()[0]).toBe editor1
@ -94,37 +94,37 @@ describe "Project", ->
beforeEach ->
absolutePath = require.resolve('./fixtures/dir/a')
newBufferHandler = jasmine.createSpy('newBufferHandler')
project.on 'buffer-created', newBufferHandler
atom.project.on 'buffer-created', newBufferHandler
newEditSessionHandler = jasmine.createSpy('newEditSessionHandler')
project.on 'editor-created', newEditSessionHandler
atom.project.on 'editor-created', newEditSessionHandler
fooOpener = (pathToOpen, options) -> { foo: pathToOpen, options } if pathToOpen?.match(/\.foo/)
barOpener = (pathToOpen) -> { bar: pathToOpen } if pathToOpen?.match(/^bar:\/\//)
project.registerOpener(fooOpener)
project.registerOpener(barOpener)
atom.project.registerOpener(fooOpener)
atom.project.registerOpener(barOpener)
afterEach ->
project.unregisterOpener(fooOpener)
project.unregisterOpener(barOpener)
atom.project.unregisterOpener(fooOpener)
atom.project.unregisterOpener(barOpener)
describe "when passed a path that doesn't match a custom opener", ->
describe "when given an absolute path that hasn't been opened previously", ->
it "returns a new edit session for the given path and emits 'buffer-created' and 'editor-created' events", ->
editor = project.openSync(absolutePath)
editor = atom.project.openSync(absolutePath)
expect(editor.buffer.getPath()).toBe absolutePath
expect(newBufferHandler).toHaveBeenCalledWith editor.buffer
expect(newEditSessionHandler).toHaveBeenCalledWith editor
describe "when given a relative path that hasn't been opened previously", ->
it "returns a new edit session for the given path (relative to the project root) and emits 'buffer-created' and 'editor-created' events", ->
editor = project.openSync('a')
editor = atom.project.openSync('a')
expect(editor.buffer.getPath()).toBe absolutePath
expect(newBufferHandler).toHaveBeenCalledWith editor.buffer
expect(newEditSessionHandler).toHaveBeenCalledWith editor
describe "when passed the path to a buffer that has already been opened", ->
it "returns a new edit session containing previously opened buffer and emits a 'editor-created' event", ->
editor = project.openSync(absolutePath)
editor = atom.project.openSync(absolutePath)
newBufferHandler.reset()
expect(project.openSync(absolutePath).buffer).toBe editor.buffer
expect(project.openSync('a').buffer).toBe editor.buffer
@ -133,14 +133,14 @@ describe "Project", ->
describe "when not passed a path", ->
it "returns a new edit session and emits 'buffer-created' and 'editor-created' events", ->
editor = project.openSync()
editor = atom.project.openSync()
expect(editor.buffer.getPath()).toBeUndefined()
expect(newBufferHandler).toHaveBeenCalledWith(editor.buffer)
expect(newEditSessionHandler).toHaveBeenCalledWith editor
describe "when passed a path that matches a custom opener", ->
it "returns the resource returned by the custom opener", ->
pathToOpen = project.resolve('a.foo')
pathToOpen = atom.project.resolve('a.foo')
expect(project.openSync(pathToOpen, hey: "there")).toEqual { foo: pathToOpen, options: {hey: "there"} }
expect(project.openSync("bar://baz")).toEqual { bar: "bar://baz" }
@ -150,25 +150,25 @@ describe "Project", ->
beforeEach ->
absolutePath = require.resolve('./fixtures/dir/a')
newBufferHandler = jasmine.createSpy('newBufferHandler')
project.on 'buffer-created', newBufferHandler
atom.project.on 'buffer-created', newBufferHandler
newEditSessionHandler = jasmine.createSpy('newEditSessionHandler')
project.on 'editor-created', newEditSessionHandler
atom.project.on 'editor-created', newEditSessionHandler
fooOpener = (pathToOpen, options) -> { foo: pathToOpen, options } if pathToOpen?.match(/\.foo/)
barOpener = (pathToOpen) -> { bar: pathToOpen } if pathToOpen?.match(/^bar:\/\//)
project.registerOpener(fooOpener)
project.registerOpener(barOpener)
atom.project.registerOpener(fooOpener)
atom.project.registerOpener(barOpener)
afterEach ->
project.unregisterOpener(fooOpener)
project.unregisterOpener(barOpener)
atom.project.unregisterOpener(fooOpener)
atom.project.unregisterOpener(barOpener)
describe "when passed a path that doesn't match a custom opener", ->
describe "when given an absolute path that isn't currently open", ->
it "returns a new edit session for the given path and emits 'buffer-created' and 'editor-created' events", ->
editor = null
waitsForPromise ->
project.open(absolutePath).then (o) -> editor = o
atom.project.open(absolutePath).then (o) -> editor = o
runs ->
expect(editor.buffer.getPath()).toBe absolutePath
@ -179,7 +179,7 @@ describe "Project", ->
it "returns a new edit session for the given path (relative to the project root) and emits 'buffer-created' and 'editor-created' events", ->
editor = null
waitsForPromise ->
project.open(absolutePath).then (o) -> editor = o
atom.project.open(absolutePath).then (o) -> editor = o
runs ->
expect(editor.buffer.getPath()).toBe absolutePath
@ -190,7 +190,7 @@ describe "Project", ->
it "returns a new edit session containing currently opened buffer and emits a 'editor-created' event", ->
editor = null
waitsForPromise ->
project.open(absolutePath).then (o) -> editor = o
atom.project.open(absolutePath).then (o) -> editor = o
runs ->
newBufferHandler.reset()
@ -203,7 +203,7 @@ describe "Project", ->
it "returns a new edit session and emits 'buffer-created' and 'editor-created' events", ->
editor = null
waitsForPromise ->
project.open().then (o) -> editor = o
atom.project.open().then (o) -> editor = o
runs ->
expect(editor.buffer.getPath()).toBeUndefined()
@ -213,18 +213,18 @@ describe "Project", ->
describe "when passed a path that matches a custom opener", ->
it "returns the resource returned by the custom opener", ->
waitsForPromise ->
pathToOpen = project.resolve('a.foo')
project.open(pathToOpen, hey: "there").then (item) ->
pathToOpen = atom.project.resolve('a.foo')
atom.project.open(pathToOpen, hey: "there").then (item) ->
expect(item).toEqual { foo: pathToOpen, options: {hey: "there"} }
waitsForPromise ->
project.open("bar://baz").then (item) ->
atom.project.open("bar://baz").then (item) ->
expect(item).toEqual { bar: "bar://baz" }
it "returns number of read bytes as progress indicator", ->
filePath = project.resolve 'a'
filePath = atom.project.resolve 'a'
totalBytes = 0
promise = project.open(filePath)
promise = atom.project.open(filePath)
promise.progress (bytesRead) -> totalBytes = bytesRead
waitsForPromise ->
@ -236,22 +236,22 @@ describe "Project", ->
describe ".bufferForPathSync(path)", ->
describe "when opening a previously opened path", ->
it "does not create a new buffer", ->
buffer = project.bufferForPathSync("a").retain()
buffer = atom.project.bufferForPathSync("a").retain()
expect(project.bufferForPathSync("a")).toBe buffer
alternativeBuffer = project.bufferForPathSync("b").retain().release()
alternativeBuffer = atom.project.bufferForPathSync("b").retain().release()
expect(alternativeBuffer).not.toBe buffer
buffer.release()
it "creates a new buffer if the previous buffer was destroyed", ->
buffer = project.bufferForPathSync("a").retain().release()
buffer = atom.project.bufferForPathSync("a").retain().release()
expect(project.bufferForPathSync("a").retain().release()).not.toBe buffer
describe ".bufferForPath(path)", ->
[buffer] = []
beforeEach ->
waitsForPromise ->
project.bufferForPath("a").then (o) ->
atom.project.bufferForPath("a").then (o) ->
buffer = o
buffer.retain()
@ -261,23 +261,23 @@ describe "Project", ->
describe "when opening a previously opened path", ->
it "does not create a new buffer", ->
waitsForPromise ->
project.bufferForPath("a").then (anotherBuffer) ->
atom.project.bufferForPath("a").then (anotherBuffer) ->
expect(anotherBuffer).toBe buffer
waitsForPromise ->
project.bufferForPath("b").then (anotherBuffer) ->
atom.project.bufferForPath("b").then (anotherBuffer) ->
expect(anotherBuffer).not.toBe buffer
it "creates a new buffer if the previous buffer was destroyed", ->
buffer.release()
waitsForPromise ->
project.bufferForPath("b").then (anotherBuffer) ->
atom.project.bufferForPath("b").then (anotherBuffer) ->
expect(anotherBuffer).not.toBe buffer
describe ".resolve(uri)", ->
describe "when passed an absolute or relative path", ->
it "returns an absolute path based on the project's root", ->
it "returns an absolute path based on the atom.project's root", ->
absolutePath = require.resolve('./fixtures/dir/a')
expect(project.resolve('a')).toBe absolutePath
expect(project.resolve(absolutePath + '/../a')).toBe absolutePath
@ -290,20 +290,20 @@ 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'))
atom.project.setPath(require.resolve('./fixtures/dir/a'))
expect(project.getPath()).toEqual path.dirname(require.resolve('./fixtures/dir/a'))
expect(project.getRootDirectory().path).toEqual path.dirname(require.resolve('./fixtures/dir/a'))
describe "when path is a directory", ->
it "sets its path to the directory and updates the root directory", ->
directory = fs.absolute(path.join(__dirname, 'fixtures', 'dir', 'a-dir'))
project.setPath(directory)
atom.project.setPath(directory)
expect(project.getPath()).toEqual directory
expect(project.getRootDirectory().path).toEqual directory
describe "when path is null", ->
it "sets its path and root directory to null", ->
project.setPath(null)
atom.project.setPath(null)
expect(project.getPath()?).toBeFalsy()
expect(project.getRootDirectory()?).toBeFalsy()
@ -311,10 +311,10 @@ describe "Project", ->
[filePath, commentFilePath, sampleContent, sampleCommentContent] = []
beforeEach ->
project.setPath(project.resolve('../'))
atom.project.setPath(project.resolve('../'))
filePath = project.resolve('sample.js')
commentFilePath = project.resolve('sample-with-comments.js')
filePath = atom.project.resolve('sample.js')
commentFilePath = atom.project.resolve('sample-with-comments.js')
sampleContent = fs.readFileSync(filePath).toString()
sampleCommentContent = fs.readFileSync(commentFilePath).toString()
@ -326,7 +326,7 @@ describe "Project", ->
it "replaces properly", ->
results = []
waitsForPromise ->
project.replace /items/gi, 'items', [filePath], (result) ->
atom.project.replace /items/gi, 'items', [filePath], (result) ->
results.push(result)
runs ->
@ -336,12 +336,12 @@ describe "Project", ->
describe "when a buffer is already open", ->
it "replaces properly and saves when not modified", ->
editor = project.openSync('sample.js')
editor = atom.project.openSync('sample.js')
expect(editor.isModified()).toBeFalsy()
results = []
waitsForPromise ->
project.replace /items/gi, 'items', [filePath], (result) ->
atom.project.replace /items/gi, 'items', [filePath], (result) ->
results.push(result)
runs ->
@ -352,13 +352,13 @@ describe "Project", ->
expect(editor.isModified()).toBeFalsy()
it "does NOT save when modified", ->
editor = project.openSync('sample.js')
editor = atom.project.openSync('sample.js')
editor.buffer.change([[0,0],[0,0]], 'omg')
expect(editor.isModified()).toBeTruthy()
results = []
waitsForPromise ->
project.replace /items/gi, 'okthen', [filePath], (result) ->
atom.project.replace /items/gi, 'okthen', [filePath], (result) ->
results.push(result)
runs ->
@ -373,12 +373,12 @@ describe "Project", ->
it "calls the callback with all regex results in all files in the project", ->
results = []
waitsForPromise ->
project.scan /(a)+/, (result) ->
atom.project.scan /(a)+/, (result) ->
results.push(result)
runs ->
expect(results).toHaveLength(3)
expect(results[0].filePath).toBe project.resolve('a')
expect(results[0].filePath).toBe atom.project.resolve('a')
expect(results[0].matches).toHaveLength(3)
expect(results[0].matches[0]).toEqual
matchText: 'aaa'
@ -389,13 +389,13 @@ describe "Project", ->
it "works with with escaped literals (like $ and ^)", ->
results = []
waitsForPromise ->
project.scan /\$\w+/, (result) -> results.push(result)
atom.project.scan /\$\w+/, (result) -> results.push(result)
runs ->
expect(results.length).toBe 1
{filePath, matches} = results[0]
expect(filePath).toBe project.resolve('a')
expect(filePath).toBe atom.project.resolve('a')
expect(matches).toHaveLength 1
expect(matches[0]).toEqual
matchText: '$bill'
@ -404,11 +404,11 @@ describe "Project", ->
range: [[2, 6], [2, 11]]
it "works on evil filenames", ->
project.setPath(path.join(__dirname, 'fixtures', 'evil-files'))
atom.project.setPath(path.join(__dirname, 'fixtures', 'evil-files'))
paths = []
matches = []
waitsForPromise ->
project.scan /evil/, (result) ->
atom.project.scan /evil/, (result) ->
paths.push(result.filePath)
matches = matches.concat(result.matches)
@ -431,7 +431,7 @@ describe "Project", ->
it "ignores case if the regex includes the `i` flag", ->
results = []
waitsForPromise ->
project.scan /DOLLAR/i, (result) -> results.push(result)
atom.project.scan /DOLLAR/i, (result) -> results.push(result)
runs ->
expect(results).toHaveLength 1
@ -441,7 +441,7 @@ describe "Project", ->
beforeEach ->
sourceProjectPath = path.join(__dirname, 'fixtures', 'git', 'working-dir')
projectPath = path.join(temp.mkdirSync("atom"))
atom.projectPath = path.join(temp.mkdirSync("atom"))
writerStream = fstream.Writer(projectPath)
fstream.Reader(sourceProjectPath).pipe(writerStream)
@ -459,26 +459,26 @@ describe "Project", ->
fs.removeSync(projectPath) if fs.existsSync(projectPath)
it "excludes ignored files", ->
project.setPath(projectPath)
atom.project.setPath(projectPath)
atom.config.set('core.excludeVcsIgnoredPaths', true)
resultHandler = jasmine.createSpy("result found")
waitsForPromise ->
project.scan /match/, (results) ->
atom.project.scan /match/, (results) ->
resultHandler()
runs ->
expect(resultHandler).not.toHaveBeenCalled()
it "includes only files when a directory filter is specified", ->
projectPath = path.join(path.join(__dirname, 'fixtures', 'dir'))
project.setPath(projectPath)
atom.projectPath = path.join(path.join(__dirname, 'fixtures', 'dir'))
atom.project.setPath(projectPath)
filePath = path.join(projectPath, 'a-dir', 'oh-git')
paths = []
matches = []
waitsForPromise ->
project.scan /aaa/, paths: ["a-dir#{path.sep}"], (result) ->
atom.project.scan /aaa/, paths: ["a-dir#{path.sep}"], (result) ->
paths.push(result.filePath)
matches = matches.concat(result.matches)
@ -488,14 +488,14 @@ describe "Project", ->
expect(matches.length).toBe 1
it "includes files and folders that begin with a '.'", ->
projectPath = temp.mkdirSync()
atom.projectPath = temp.mkdirSync()
filePath = path.join(projectPath, '.text')
fs.writeFileSync(filePath, 'match this')
project.setPath(projectPath)
atom.project.setPath(projectPath)
paths = []
matches = []
waitsForPromise ->
project.scan /match this/, (result) ->
atom.project.scan /match this/, (result) ->
paths.push(result.filePath)
matches = matches.concat(result.matches)
@ -505,25 +505,25 @@ describe "Project", ->
expect(matches.length).toBe 1
it "excludes values in core.ignoredNames", ->
projectPath = path.join(__dirname, 'fixtures', 'git', 'working-dir')
atom.projectPath = path.join(__dirname, 'fixtures', 'git', 'working-dir')
ignoredNames = atom.config.get("core.ignoredNames")
ignoredNames.push("a")
atom.config.set("core.ignoredNames", ignoredNames)
resultHandler = jasmine.createSpy("result found")
waitsForPromise ->
project.scan /dollar/, (results) ->
atom.project.scan /dollar/, (results) ->
resultHandler()
runs ->
expect(resultHandler).not.toHaveBeenCalled()
it "scans buffer contents if the buffer is modified", ->
editor = project.openSync("a")
editor = atom.project.openSync("a")
editor.setText("Elephant")
results = []
waitsForPromise ->
project.scan /a|Elephant/, (result) -> results.push result
atom.project.scan /a|Elephant/, (result) -> results.push result
runs ->
expect(results).toHaveLength 3

View File

@ -8,45 +8,45 @@ describe "RootView", ->
pathToOpen = null
beforeEach ->
project.setPath(project.resolve('dir'))
pathToOpen = project.resolve('a')
atom.project.setPath(project.resolve('dir'))
pathToOpen = atom.project.resolve('a')
atom.rootView = new RootView
rootView.enableKeymap()
rootView.openSync(pathToOpen)
rootView.focus()
atom.rootView.enableKeymap()
atom.rootView.openSync(pathToOpen)
atom.rootView.focus()
describe "@deserialize()", ->
viewState = null
refreshRootViewAndProject = ->
rootViewState = rootView.serialize()
project.getState().serializeForPersistence()
project2 = atom.replicate().get('project')
rootView.remove()
project.destroy()
window.project = project2
atom.rootViewState = atom.rootView.serialize()
atom.project.getState().serializeForPersistence()
atom.rootView.remove()
atom.project.destroy()
atom.rootView = atom.deserializers.deserialize(rootViewState)
rootView.attachToDom()
atom.rootView.attachToDom()
describe "when the serialized RootView has an unsaved buffer", ->
it "constructs the view with the same panes", ->
rootView.attachToDom()
rootView.openSync()
editor1 = rootView.getActiveView()
atom.rootView.attachToDom()
atom.rootView.openSync()
editor1 = atom.rootView.getActiveView()
buffer = editor1.getBuffer()
editor1.splitRight()
expect(rootView.getActiveView()).toBe rootView.getEditors()[2]
expect(rootView.getActiveView()).toBe atom.rootView.getEditors()[2]
refreshRootViewAndProject()
expect(rootView.getEditors().length).toBe 2
expect(rootView.getActiveView()).toBe rootView.getEditors()[1]
expect(rootView.getActiveView()).toBe atom.rootView.getEditors()[1]
expect(rootView.title).toBe "untitled - #{project.getPath()}"
describe "when there are open editors", ->
it "constructs the view with the same panes", ->
rootView.attachToDom()
pane1 = rootView.getActivePane()
atom.rootView.attachToDom()
pane1 = atom.rootView.getActivePane()
pane2 = pane1.splitRight()
pane3 = pane2.splitRight()
pane4 = pane2.splitDown()
@ -60,16 +60,16 @@ describe "RootView", ->
refreshRootViewAndProject()
expect(rootView.getEditors().length).toBe 4
editor1 = rootView.panes.find('.row > .pane .editor:eq(0)').view()
editor3 = rootView.panes.find('.row > .pane .editor:eq(1)').view()
editor2 = rootView.panes.find('.row > .column > .pane .editor:eq(0)').view()
editor4 = rootView.panes.find('.row > .column > .pane .editor:eq(1)').view()
editor1 = atom.rootView.panes.find('.row > .pane .editor:eq(0)').view()
editor3 = atom.rootView.panes.find('.row > .pane .editor:eq(1)').view()
editor2 = atom.rootView.panes.find('.row > .column > .pane .editor:eq(0)').view()
editor4 = atom.rootView.panes.find('.row > .column > .pane .editor:eq(1)').view()
expect(editor1.getPath()).toBe project.resolve('a')
expect(editor2.getPath()).toBe project.resolve('b')
expect(editor3.getPath()).toBe project.resolve('../sample.js')
expect(editor1.getPath()).toBe atom.project.resolve('a')
expect(editor2.getPath()).toBe atom.project.resolve('b')
expect(editor3.getPath()).toBe atom.project.resolve('../sample.js')
expect(editor3.getCursorScreenPosition()).toEqual [2, 4]
expect(editor4.getPath()).toBe project.resolve('../sample.txt')
expect(editor4.getPath()).toBe atom.project.resolve('../sample.txt')
expect(editor4.getCursorScreenPosition()).toEqual [0, 2]
# ensure adjust pane dimensions is called
@ -88,177 +88,177 @@ describe "RootView", ->
describe "where there are no open editors", ->
it "constructs the view with no open editors", ->
rootView.getActivePane().remove()
atom.rootView.getActivePane().remove()
expect(rootView.getEditors().length).toBe 0
refreshRootViewAndProject()
expect(rootView.getEditors().length).toBe 0
describe "focus", ->
beforeEach ->
rootView.attachToDom()
atom.rootView.attachToDom()
describe "when there is an active view", ->
it "hands off focus to the active view", ->
editorView = rootView.getActiveView()
editorView = atom.rootView.getActiveView()
editorView.isFocused = false
rootView.focus()
atom.rootView.focus()
expect(editorView.isFocused).toBeTruthy()
describe "when there is no active view", ->
beforeEach ->
rootView.getActivePane().remove()
atom.rootView.getActivePane().remove()
expect(rootView.getActiveView()).toBeUndefined()
rootView.attachToDom()
atom.rootView.attachToDom()
expect(document.activeElement).toBe document.body
describe "when are visible focusable elements (with a -1 tabindex)", ->
it "passes focus to the first focusable element", ->
focusable1 = $$ -> @div "One", id: 'one', tabindex: -1
focusable2 = $$ -> @div "Two", id: 'two', tabindex: -1
rootView.horizontal.append(focusable1, focusable2)
atom.rootView.horizontal.append(focusable1, focusable2)
expect(document.activeElement).toBe document.body
rootView.focus()
atom.rootView.focus()
expect(document.activeElement).toBe focusable1[0]
describe "when there are no visible focusable elements", ->
it "surrenders focus to the body", ->
focusable = $$ -> @div "One", id: 'one', tabindex: -1
rootView.horizontal.append(focusable)
atom.rootView.horizontal.append(focusable)
focusable.hide()
expect(document.activeElement).toBe document.body
rootView.focus()
atom.rootView.focus()
expect(document.activeElement).toBe document.body
describe "keymap wiring", ->
commandHandler = null
beforeEach ->
commandHandler = jasmine.createSpy('commandHandler')
rootView.on('foo-command', commandHandler)
atom.rootView.on('foo-command', commandHandler)
atom.keymap.bindKeys('name', '*', 'x': 'foo-command')
describe "when a keydown event is triggered in the RootView", ->
it "triggers matching keybindings for that event", ->
event = keydownEvent 'x', target: rootView[0]
event = keydownEvent 'x', target: atom.rootView[0]
rootView.trigger(event)
atom.rootView.trigger(event)
expect(commandHandler).toHaveBeenCalled()
describe "window title", ->
describe "when the project has no path", ->
it "sets the title to 'untitled'", ->
project.setPath(undefined)
atom.project.setPath(undefined)
expect(rootView.title).toBe 'untitled'
describe "when the project has a path", ->
beforeEach ->
rootView.openSync('b')
atom.rootView.openSync('b')
describe "when there is an active pane item", ->
it "sets the title to the pane item's title plus the project path", ->
item = rootView.getActivePaneItem()
item = atom.rootView.getActivePaneItem()
expect(rootView.title).toBe "#{item.getTitle()} - #{project.getPath()}"
describe "when the title of the active pane item changes", ->
it "updates the window title based on the item's new title", ->
editor = rootView.getActivePaneItem()
editor = atom.rootView.getActivePaneItem()
editor.buffer.setPath(path.join(temp.dir, 'hi'))
expect(rootView.title).toBe "#{editor.getTitle()} - #{project.getPath()}"
describe "when the active pane's item changes", ->
it "updates the title to the new item's title plus the project path", ->
rootView.getActivePane().showNextItem()
item = rootView.getActivePaneItem()
atom.rootView.getActivePane().showNextItem()
item = atom.rootView.getActivePaneItem()
expect(rootView.title).toBe "#{item.getTitle()} - #{project.getPath()}"
describe "when the last pane item is removed", ->
it "updates the title to contain the project's path", ->
rootView.getActivePane().remove()
atom.rootView.getActivePane().remove()
expect(rootView.getActivePaneItem()).toBeUndefined()
expect(rootView.title).toBe project.getPath()
expect(rootView.title).toBe atom.project.getPath()
describe "when an inactive pane's item changes", ->
it "does not update the title", ->
pane = rootView.getActivePane()
pane = atom.rootView.getActivePane()
pane.splitRight()
initialTitle = rootView.title
initialTitle = atom.rootView.title
pane.showNextItem()
expect(rootView.title).toBe initialTitle
describe "when the root view is deserialized", ->
it "updates the title to contain the project's path", ->
rootView2 = atom.deserializers.deserialize(rootView.serialize())
item = rootView.getActivePaneItem()
item = atom.rootView.getActivePaneItem()
expect(rootView2.title).toBe "#{item.getTitle()} - #{project.getPath()}"
rootView2.remove()
describe "font size adjustment", ->
it "increases/decreases font size when increase/decrease-font-size events are triggered", ->
fontSizeBefore = atom.config.get('editor.fontSize')
rootView.trigger 'window:increase-font-size'
atom.rootView.trigger 'window:increase-font-size'
expect(atom.config.get('editor.fontSize')).toBe fontSizeBefore + 1
rootView.trigger 'window:increase-font-size'
atom.rootView.trigger 'window:increase-font-size'
expect(atom.config.get('editor.fontSize')).toBe fontSizeBefore + 2
rootView.trigger 'window:decrease-font-size'
atom.rootView.trigger 'window:decrease-font-size'
expect(atom.config.get('editor.fontSize')).toBe fontSizeBefore + 1
rootView.trigger 'window:decrease-font-size'
atom.rootView.trigger 'window:decrease-font-size'
expect(atom.config.get('editor.fontSize')).toBe fontSizeBefore
it "does not allow the font size to be less than 1", ->
atom.config.set("editor.fontSize", 1)
rootView.trigger 'window:decrease-font-size'
atom.rootView.trigger 'window:decrease-font-size'
expect(atom.config.get('editor.fontSize')).toBe 1
describe ".openSync(filePath, options)", ->
describe "when there is no active pane", ->
beforeEach ->
spyOn(Pane.prototype, 'focus')
rootView.getActivePane().remove()
atom.rootView.getActivePane().remove()
expect(rootView.getActivePane()).toBeUndefined()
describe "when called with no path", ->
it "creates a empty edit session as an item on a new pane, and focuses the pane", ->
editor = rootView.openSync()
editor = atom.rootView.openSync()
expect(rootView.getActivePane().activeItem).toBe editor
expect(editor.getPath()).toBeUndefined()
expect(rootView.getActivePane().focus).toHaveBeenCalled()
it "can create multiple empty edit sessions as an item on a new pane", ->
editor = rootView.openSync()
editor2 = rootView.openSync()
editor = atom.rootView.openSync()
editor2 = atom.rootView.openSync()
expect(rootView.getActivePane().getItems().length).toBe 2
expect(editor).not.toBe editor2
describe "when called with a path", ->
it "creates an edit session for the given path as an item on a new pane, and focuses the pane", ->
editor = rootView.openSync('b')
editor = atom.rootView.openSync('b')
expect(rootView.getActivePane().activeItem).toBe editor
expect(editor.getPath()).toBe require.resolve('./fixtures/dir/b')
expect(rootView.getActivePane().focus).toHaveBeenCalled()
describe "when the changeFocus option is false", ->
it "does not focus the new pane", ->
editor = rootView.openSync('b', changeFocus: false)
editor = atom.rootView.openSync('b', changeFocus: false)
expect(rootView.getActivePane().focus).not.toHaveBeenCalled()
describe "when the split option is 'right'", ->
it "creates a new pane and opens the file in said pane", ->
editor = rootView.openSync('b', split: 'right')
editor = atom.rootView.openSync('b', split: 'right')
expect(rootView.getActivePane().activeItem).toBe editor
expect(editor.getPath()).toBe require.resolve('./fixtures/dir/b')
describe "when there is an active pane", ->
[activePane, initialItemCount] = []
beforeEach ->
activePane = rootView.getActivePane()
activePane = atom.rootView.getActivePane()
spyOn(activePane, 'focus')
initialItemCount = activePane.getItems().length
describe "when called with no path", ->
it "opens an edit session with an empty buffer as an item in the active pane and focuses it", ->
editor = rootView.openSync()
editor = atom.rootView.openSync()
expect(activePane.getItems().length).toBe initialItemCount + 1
expect(activePane.activeItem).toBe editor
expect(editor.getPath()).toBeUndefined()
@ -269,11 +269,11 @@ describe "RootView", ->
it "shows the existing edit session in the pane", ->
previousEditSession = activePane.activeItem
editor = rootView.openSync('b')
editor = atom.rootView.openSync('b')
expect(activePane.activeItem).toBe editor
expect(editor).not.toBe previousEditSession
editor = rootView.openSync(previousEditSession.getPath())
editor = atom.rootView.openSync(previousEditSession.getPath())
expect(editor).toBe previousEditSession
expect(activePane.activeItem).toBe editor
@ -281,29 +281,29 @@ describe "RootView", ->
describe "when the active pane does not have an edit session item for the path being opened", ->
it "creates a new edit session for the given path in the active editor", ->
editor = rootView.openSync('b')
editor = atom.rootView.openSync('b')
expect(activePane.items.length).toBe 2
expect(activePane.activeItem).toBe editor
expect(activePane.focus).toHaveBeenCalled()
describe "when the changeFocus option is false", ->
it "does not focus the active pane", ->
editor = rootView.openSync('b', changeFocus: false)
editor = atom.rootView.openSync('b', changeFocus: false)
expect(activePane.focus).not.toHaveBeenCalled()
describe "when the split option is 'right'", ->
it "creates a new pane and opens the file in said pane", ->
pane1 = rootView.getActivePane()
pane1 = atom.rootView.getActivePane()
editor = rootView.openSync('b', split: 'right')
pane2 = rootView.getActivePane()
editor = atom.rootView.openSync('b', split: 'right')
pane2 = atom.rootView.getActivePane()
expect(pane2[0]).not.toBe pane1[0]
expect(editor.getPath()).toBe require.resolve('./fixtures/dir/b')
expect(rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
editor = rootView.openSync('file1', split: 'right')
pane3 = rootView.getActivePane()
editor = atom.rootView.openSync('file1', split: 'right')
pane3 = atom.rootView.getActivePane()
expect(pane3[0]).toBe pane2[0]
expect(editor.getPath()).toBe require.resolve('./fixtures/dir/file1')
@ -314,11 +314,11 @@ describe "RootView", ->
[pane1] = []
beforeEach ->
spyOn(Pane.prototype, 'focus').andCallFake -> @makeActive()
pane1 = rootView.getActivePane()
pane1 = atom.rootView.getActivePane()
it "creates a new pane and reuses the file when already open", ->
rootView.openSingletonSync('b', split: 'right')
pane2 = rootView.getActivePane()
atom.rootView.openSingletonSync('b', split: 'right')
pane2 = atom.rootView.getActivePane()
expect(pane2[0]).not.toBe pane1[0]
expect(pane1.itemForUri('b')).toBeFalsy()
expect(pane2.itemForUri('b')).not.toBeFalsy()
@ -327,21 +327,21 @@ describe "RootView", ->
pane1.focus()
expect(rootView.getActivePane()[0]).toBe pane1[0]
rootView.openSingletonSync('b', split: 'right')
pane3 = rootView.getActivePane()
atom.rootView.openSingletonSync('b', split: 'right')
pane3 = atom.rootView.getActivePane()
expect(pane3[0]).toBe pane2[0]
expect(pane1.itemForUri('b')).toBeFalsy()
expect(pane2.itemForUri('b')).not.toBeFalsy()
expect(rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
it "handles split: left by opening to the left pane when necessary", ->
rootView.openSingletonSync('b', split: 'right')
pane2 = rootView.getActivePane()
atom.rootView.openSingletonSync('b', split: 'right')
pane2 = atom.rootView.getActivePane()
expect(pane2[0]).not.toBe pane1[0]
rootView.openSingletonSync('file1', split: 'left')
atom.rootView.openSingletonSync('file1', split: 'left')
activePane = rootView.getActivePane()
activePane = atom.rootView.getActivePane()
expect(activePane[0]).toBe pane1[0]
expect(pane1.itemForUri('file1')).toBeTruthy()
@ -351,14 +351,14 @@ describe "RootView", ->
pane2.focus()
expect(rootView.getActivePane()[0]).toBe pane2[0]
rootView.openSingletonSync('file1', split: 'left')
activePane = rootView.getActivePane()
atom.rootView.openSingletonSync('file1', split: 'left')
activePane = atom.rootView.getActivePane()
expect(activePane[0]).toBe pane1[0]
expect(rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
it "reuses the file when already open", ->
rootView.openSync('b')
rootView.openSingletonSync('b', split: 'right')
atom.rootView.openSync('b')
atom.rootView.openSingletonSync('b', split: 'right')
expect(rootView.panes.find('.pane').toArray()).toEqual [pane1[0]]
describe ".open(filePath)", ->
@ -367,7 +367,7 @@ describe "RootView", ->
describe "when there is no active pane", ->
beforeEach ->
rootView.getActivePane().remove()
atom.rootView.getActivePane().remove()
expect(rootView.getActivePane()).toBeUndefined()
describe "when called with no path", ->
@ -375,7 +375,7 @@ describe "RootView", ->
editor = null
waitsForPromise ->
rootView.open().then (o) -> editor = o
atom.rootView.open().then (o) -> editor = o
runs ->
expect(rootView.getActivePane().activeItem).toBe editor
@ -387,10 +387,10 @@ describe "RootView", ->
editor2 = null
waitsForPromise ->
rootView.open()
atom.rootView.open()
.then (o) ->
editor1 = o
rootView.open()
atom.rootView.open()
.then (o) ->
editor2 = o
@ -402,7 +402,7 @@ describe "RootView", ->
it "creates an edit session for the given path as an item on a new pane, and focuses the pane", ->
editor = null
waitsForPromise ->
rootView.open('b').then (o) -> editor = o
atom.rootView.open('b').then (o) -> editor = o
runs ->
expect(rootView.getActivePane().activeItem).toBe editor
@ -413,14 +413,14 @@ describe "RootView", ->
[activePane] = []
beforeEach ->
activePane = rootView.getActivePane()
activePane = atom.rootView.getActivePane()
describe "when called with no path", ->
it "opens an edit session with an empty buffer as an item in the active pane and focuses it", ->
editor = null
waitsForPromise ->
rootView.open().then (o) -> editor = o
atom.rootView.open().then (o) -> editor = o
runs ->
expect(activePane.getItems().length).toBe 2
@ -435,14 +435,14 @@ describe "RootView", ->
editor = null
waitsForPromise ->
rootView.open('b').then (o) -> editor = o
atom.rootView.open('b').then (o) -> editor = o
runs ->
expect(activePane.activeItem).toBe editor
expect(editor).not.toBe previousEditSession
waitsForPromise ->
rootView.open(previousEditSession.getPath()).then (o) -> editor = o
atom.rootView.open(previousEditSession.getPath()).then (o) -> editor = o
runs ->
expect(editor).toBe previousEditSession
@ -454,7 +454,7 @@ describe "RootView", ->
editor = null
waitsForPromise ->
rootView.open('b').then (o) -> editor = o
atom.rootView.open('b').then (o) -> editor = o
runs ->
expect(activePane.activeItem).toBe editor
@ -463,9 +463,9 @@ describe "RootView", ->
describe "window:toggle-invisibles event", ->
it "shows/hides invisibles in all open and future editors", ->
rootView.height(200)
rootView.attachToDom()
rightEditor = rootView.getActiveView()
atom.rootView.height(200)
atom.rootView.attachToDom()
rightEditor = atom.rootView.getActiveView()
rightEditor.setText(" \t ")
leftEditor = rightEditor.splitLeft()
expect(rightEditor.find(".line:first").text()).toBe " "
@ -473,14 +473,14 @@ describe "RootView", ->
withInvisiblesShowing = "#{rightEditor.invisibles.space}#{rightEditor.invisibles.tab} #{rightEditor.invisibles.space}#{rightEditor.invisibles.eol}"
rootView.trigger "window:toggle-invisibles"
atom.rootView.trigger "window:toggle-invisibles"
expect(rightEditor.find(".line:first").text()).toBe withInvisiblesShowing
expect(leftEditor.find(".line:first").text()).toBe withInvisiblesShowing
lowerLeftEditor = leftEditor.splitDown()
expect(lowerLeftEditor.find(".line:first").text()).toBe withInvisiblesShowing
rootView.trigger "window:toggle-invisibles"
atom.rootView.trigger "window:toggle-invisibles"
expect(rightEditor.find(".line:first").text()).toBe " "
expect(leftEditor.find(".line:first").text()).toBe " "
@ -489,7 +489,7 @@ describe "RootView", ->
describe ".eachEditor(callback)", ->
beforeEach ->
rootView.attachToDom()
atom.rootView.attachToDom()
it "invokes the callback for existing editor", ->
count = 0
@ -497,9 +497,9 @@ describe "RootView", ->
callback = (editor) ->
callbackEditor = editor
count++
rootView.eachEditor(callback)
atom.rootView.eachEditor(callback)
expect(count).toBe 1
expect(callbackEditor).toBe rootView.getActiveView()
expect(callbackEditor).toBe atom.rootView.getActiveView()
it "invokes the callback for new editor", ->
count = 0
@ -508,28 +508,28 @@ describe "RootView", ->
callbackEditor = editor
count++
rootView.eachEditor(callback)
atom.rootView.eachEditor(callback)
count = 0
callbackEditor = null
rootView.getActiveView().splitRight()
atom.rootView.getActiveView().splitRight()
expect(count).toBe 1
expect(callbackEditor).toBe rootView.getActiveView()
expect(callbackEditor).toBe atom.rootView.getActiveView()
it "returns a subscription that can be disabled", ->
count = 0
callback = (editor) -> count++
subscription = rootView.eachEditor(callback)
subscription = atom.rootView.eachEditor(callback)
expect(count).toBe 1
rootView.getActiveView().splitRight()
atom.rootView.getActiveView().splitRight()
expect(count).toBe 2
subscription.off()
rootView.getActiveView().splitRight()
atom.rootView.getActiveView().splitRight()
expect(count).toBe 2
describe ".eachBuffer(callback)", ->
beforeEach ->
rootView.attachToDom()
atom.rootView.attachToDom()
it "invokes the callback for existing buffer", ->
count = 0
@ -538,9 +538,9 @@ describe "RootView", ->
callback = (buffer) ->
callbackBuffer = buffer
count++
rootView.eachBuffer(callback)
atom.rootView.eachBuffer(callback)
expect(count).toBe 1
expect(callbackBuffer).toBe rootView.getActiveView().getBuffer()
expect(callbackBuffer).toBe atom.rootView.getActiveView().getBuffer()
it "invokes the callback for new buffer", ->
count = 0
@ -549,9 +549,9 @@ describe "RootView", ->
callbackBuffer = buffer
count++
rootView.eachBuffer(callback)
atom.rootView.eachBuffer(callback)
count = 0
callbackBuffer = null
rootView.openSync(require.resolve('./fixtures/sample.txt'))
atom.rootView.openSync(require.resolve('./fixtures/sample.txt'))
expect(count).toBe 1
expect(callbackBuffer).toBe rootView.getActiveView().getBuffer()
expect(callbackBuffer).toBe atom.rootView.getActiveView().getBuffer()

View File

@ -4,7 +4,7 @@ describe "Selection", ->
[buffer, editor, selection] = []
beforeEach ->
buffer = project.bufferForPathSync('sample.js')
buffer = atom.project.bufferForPathSync('sample.js')
editor = new Editor(buffer: buffer, tabLength: 2)
selection = editor.getSelection()

View File

@ -10,7 +10,7 @@ describe 'TextBuffer', ->
beforeEach ->
filePath = require.resolve('./fixtures/sample.js')
fileContents = fs.readFileSync(filePath, 'utf8')
buffer = project.bufferForPathSync(filePath)
buffer = atom.project.bufferForPathSync(filePath)
afterEach ->
buffer?.destroy()
@ -24,12 +24,12 @@ describe 'TextBuffer', ->
describe "when a file exists for the path", ->
it "loads the contents of that file", ->
filePath = require.resolve './fixtures/sample.txt'
buffer = project.bufferForPathSync(filePath)
buffer = atom.project.bufferForPathSync(filePath)
expect(buffer.getText()).toBe fs.readFileSync(filePath, 'utf8')
it "does not allow the initial state of the buffer to be undone", ->
filePath = require.resolve './fixtures/sample.txt'
buffer = project.bufferForPathSync(filePath)
buffer = atom.project.bufferForPathSync(filePath)
buffer.undo()
expect(buffer.getText()).toBe fs.readFileSync(filePath, 'utf8')
@ -37,13 +37,13 @@ describe 'TextBuffer', ->
it "is modified and is initially empty", ->
filePath = "does-not-exist.txt"
expect(fs.existsSync(filePath)).toBeFalsy()
buffer = project.bufferForPathSync(filePath)
buffer = atom.project.bufferForPathSync(filePath)
expect(buffer.isModified()).toBeTruthy()
expect(buffer.getText()).toBe ''
describe "when no path is given", ->
it "creates an empty buffer", ->
buffer = project.bufferForPathSync(null)
buffer = atom.project.bufferForPathSync(null)
expect(buffer .getText()).toBe ""
describe "path-changed event", ->
@ -53,7 +53,7 @@ describe 'TextBuffer', ->
filePath = path.join(__dirname, "fixtures", "atom-manipulate-me")
newPath = "#{filePath}-i-moved"
fs.writeFileSync(filePath, "")
bufferToChange = project.bufferForPathSync(filePath)
bufferToChange = atom.project.bufferForPathSync(filePath)
eventHandler = jasmine.createSpy('eventHandler')
bufferToChange.on 'path-changed', eventHandler
@ -85,7 +85,7 @@ describe 'TextBuffer', ->
buffer.release()
filePath = temp.openSync('atom').path
fs.writeFileSync(filePath, "first")
buffer = project.bufferForPathSync(filePath).retain()
buffer = atom.project.bufferForPathSync(filePath).retain()
afterEach ->
buffer.release()
@ -156,7 +156,7 @@ describe 'TextBuffer', ->
beforeEach ->
filePath = path.join(temp.dir, 'atom-file-to-delete.txt')
fs.writeFileSync(filePath, 'delete me')
bufferToDelete = project.bufferForPathSync(filePath)
bufferToDelete = atom.project.bufferForPathSync(filePath)
filePath = bufferToDelete.getPath() # symlinks may have been converted
expect(bufferToDelete.getPath()).toBe filePath
@ -214,7 +214,7 @@ describe 'TextBuffer', ->
buffer.release()
filePath = path.join(temp.dir, 'atom-tmp-file')
fs.writeFileSync(filePath, 'delete me')
buffer = project.bufferForPathSync(filePath)
buffer = atom.project.bufferForPathSync(filePath)
modifiedHandler = jasmine.createSpy("modifiedHandler")
buffer.on 'modified-status-changed', modifiedHandler
@ -227,7 +227,7 @@ describe 'TextBuffer', ->
filePath = path.join(temp.dir, 'atom-tmp-file')
fs.writeFileSync(filePath, '')
buffer.release()
buffer = project.bufferForPathSync(filePath)
buffer = atom.project.bufferForPathSync(filePath)
modifiedHandler = jasmine.createSpy("modifiedHandler")
buffer.on 'modified-status-changed', modifiedHandler
@ -251,7 +251,7 @@ describe 'TextBuffer', ->
filePath = path.join(temp.dir, 'atom-tmp-file')
fs.writeFileSync(filePath, '')
buffer.release()
buffer = project.bufferForPathSync(filePath)
buffer = atom.project.bufferForPathSync(filePath)
modifiedHandler = jasmine.createSpy("modifiedHandler")
buffer.on 'modified-status-changed', modifiedHandler
@ -275,7 +275,7 @@ describe 'TextBuffer', ->
fs.removeSync(filePath) if fs.existsSync(filePath)
expect(fs.existsSync(filePath)).toBeFalsy()
buffer.release()
buffer = project.bufferForPathSync(filePath)
buffer = atom.project.bufferForPathSync(filePath)
modifiedHandler = jasmine.createSpy("modifiedHandler")
buffer.on 'modified-status-changed', modifiedHandler
@ -298,12 +298,12 @@ describe 'TextBuffer', ->
it "returns false for an empty buffer with no path", ->
buffer.release()
buffer = project.bufferForPathSync(null)
buffer = atom.project.bufferForPathSync(null)
expect(buffer.isModified()).toBeFalsy()
it "returns true for a non-empty buffer with no path", ->
buffer.release()
buffer = project.bufferForPathSync(null)
buffer = atom.project.bufferForPathSync(null)
buffer.setText('a')
expect(buffer.isModified()).toBeTruthy()
buffer.setText('\n')
@ -312,7 +312,7 @@ describe 'TextBuffer', ->
it "returns false until the buffer is fully loaded", ->
buffer.release()
buffer = new TextBuffer({filePath: temp.openSync('atom').path})
project.addBuffer(buffer)
atom.project.addBuffer(buffer)
expect(buffer.isModified()).toBeFalsy()
@ -466,7 +466,7 @@ describe 'TextBuffer', ->
beforeEach ->
filePath = path.join(temp.dir, 'temp.txt')
fs.writeFileSync(filePath, "")
saveBuffer = project.bufferForPathSync(filePath)
saveBuffer = atom.project.bufferForPathSync(filePath)
saveBuffer.setText("blah")
it "saves the contents of the buffer to the path", ->
@ -500,7 +500,7 @@ describe 'TextBuffer', ->
describe "when the buffer has no path", ->
it "throws an exception", ->
saveBuffer = project.bufferForPathSync(null)
saveBuffer = atom.project.bufferForPathSync(null)
saveBuffer.setText "hi"
expect(-> saveBuffer.save()).toThrow()
@ -524,7 +524,7 @@ describe 'TextBuffer', ->
filePath = path.join(temp.dir, 'temp.txt')
fs.removeSync filePath if fs.existsSync(filePath)
saveAsBuffer = project.bufferForPathSync(null).retain()
saveAsBuffer = atom.project.bufferForPathSync(null).retain()
eventHandler = jasmine.createSpy('eventHandler')
saveAsBuffer.on 'path-changed', eventHandler
@ -539,7 +539,7 @@ describe 'TextBuffer', ->
newPath = path.join(temp.dir, 'new.txt')
fs.writeFileSync(originalPath, "")
saveAsBuffer = project.bufferForPathSync(originalPath).retain()
saveAsBuffer = atom.project.bufferForPathSync(originalPath).retain()
changeHandler = jasmine.createSpy('changeHandler')
saveAsBuffer.on 'changed', changeHandler
saveAsBuffer.saveAs(newPath)
@ -904,7 +904,7 @@ describe 'TextBuffer', ->
filePath = temp.openSync('atom').path
fs.writeFileSync(filePath, "words")
buffer = project.bufferForPathSync(filePath)
buffer = atom.project.bufferForPathSync(filePath)
afterEach ->
buffer2?.release()
@ -966,13 +966,13 @@ describe 'TextBuffer', ->
it "restores the previous unsaved state of the buffer", ->
buffer.release()
buffer = project.bufferForPathSync()
buffer = atom.project.bufferForPathSync()
buffer.setText("abc")
state = buffer.getState().clone()
expect(state.get('path')).toBeUndefined()
expect(state.getObject('text')).toBe 'abc'
buffer2 = project.addBuffer(new TextBuffer(state))
buffer2 = atom.project.addBuffer(new TextBuffer(state))
expect(buffer2.getPath()).toBeUndefined()
expect(buffer2.getText()).toBe("abc")

View File

@ -447,7 +447,7 @@ describe "TextMateGrammar", ->
describe "when the grammar is added", ->
it "retokenizes existing buffers that contain tokens that match the injection selector", ->
editor = project.openSync('sample.js')
editor = atom.project.openSync('sample.js')
editor.setText("// http://github.com")
{tokens} = editor.lineForScreenRow(0)
@ -462,7 +462,7 @@ describe "TextMateGrammar", ->
describe "when the grammar is updated", ->
it "retokenizes existing buffers that contain tokens that match the injection selector", ->
editor = project.openSync('sample.js')
editor = atom.project.openSync('sample.js')
editor.setText("// SELECT * FROM OCTOCATS")
{tokens} = editor.lineForScreenRow(0)

View File

@ -80,7 +80,7 @@ describe "ThemeManager", ->
describe "requireStylesheet(path)", ->
it "synchronously loads css at the given path and installs a style tag for it in the head", ->
cssPath = project.resolve('css.css')
cssPath = atom.project.resolve('css.css')
lengthBefore = $('head style').length
themeManager.requireStylesheet(cssPath)
@ -97,7 +97,7 @@ describe "ThemeManager", ->
$('head style[id*="css.css"]').remove()
it "synchronously loads and parses less files at the given path and installs a style tag for it in the head", ->
lessPath = project.resolve('sample.less')
lessPath = atom.project.resolve('sample.less')
lengthBefore = $('head style').length
themeManager.requireStylesheet(lessPath)
expect($('head style').length).toBe lengthBefore + 1
@ -141,8 +141,8 @@ describe "ThemeManager", ->
describe "base stylesheet loading", ->
beforeEach ->
atom.rootView = new RootView
rootView.append $$ -> @div class: 'editor'
rootView.attachToDom()
atom.rootView.append $$ -> @div class: 'editor'
atom.rootView.attachToDom()
themeManager.activateThemes()
it "loads the correct values from the theme's ui-variables file", ->

View File

@ -20,7 +20,7 @@ describe "TokenizedBuffer", ->
describe "@deserialize(state)", ->
it "constructs a tokenized buffer with the same buffer and tabLength setting", ->
buffer = project.bufferForPathSync('sample.js')
buffer = atom.project.bufferForPathSync('sample.js')
tokenizedBuffer1 = new TokenizedBuffer(buffer: buffer, tabLength: 4)
tokenizedBuffer2 = atom.deserializers.deserialize(tokenizedBuffer1.serialize())
expect(tokenizedBuffer2.buffer).toBe tokenizedBuffer1.buffer
@ -28,7 +28,7 @@ describe "TokenizedBuffer", ->
describe "when the buffer is destroyed", ->
beforeEach ->
buffer = project.bufferForPathSync('sample.js')
buffer = atom.project.bufferForPathSync('sample.js')
tokenizedBuffer = new TokenizedBuffer({buffer})
startTokenizing(tokenizedBuffer)
@ -40,7 +40,7 @@ describe "TokenizedBuffer", ->
describe "when the buffer contains soft-tabs", ->
beforeEach ->
buffer = project.bufferForPathSync('sample.js')
buffer = atom.project.bufferForPathSync('sample.js')
tokenizedBuffer = new TokenizedBuffer({buffer})
startTokenizing(tokenizedBuffer)
tokenizedBuffer.on "changed", changeHandler = jasmine.createSpy('changeHandler')
@ -320,7 +320,7 @@ describe "TokenizedBuffer", ->
describe "when the buffer contains hard-tabs", ->
beforeEach ->
atom.packages.activatePackage('language-coffee-script', sync: true)
buffer = project.bufferForPathSync('sample-with-tabs.coffee')
buffer = atom.project.bufferForPathSync('sample-with-tabs.coffee')
tokenizedBuffer = new TokenizedBuffer({buffer})
startTokenizing(tokenizedBuffer)
@ -350,7 +350,7 @@ describe "TokenizedBuffer", ->
describe "when the buffer contains surrogate pairs", ->
beforeEach ->
atom.packages.activatePackage('language-javascript', sync: true)
buffer = project.bufferForPathSync 'sample-with-pairs.js'
buffer = atom.project.bufferForPathSync 'sample-with-pairs.js'
buffer.setText """
'abc\uD835\uDF97def'
//\uD835\uDF97xyz
@ -390,7 +390,7 @@ describe "TokenizedBuffer", ->
atom.packages.activatePackage('language-ruby-on-rails', sync: true)
atom.packages.activatePackage('language-ruby', sync: true)
buffer = project.bufferForPathSync()
buffer = atom.project.bufferForPathSync()
buffer.setText "<div class='name'><%= User.find(2).full_name %></div>"
tokenizedBuffer = new TokenizedBuffer({buffer})
tokenizedBuffer.setGrammar(atom.syntax.selectGrammar('test.erb'))
@ -410,7 +410,7 @@ describe "TokenizedBuffer", ->
buffer.release()
it "returns the correct token (regression)", ->
buffer = project.bufferForPathSync('sample.js')
buffer = atom.project.bufferForPathSync('sample.js')
tokenizedBuffer = new TokenizedBuffer({buffer})
fullyTokenize(tokenizedBuffer)
expect(tokenizedBuffer.tokenForPosition([1,0]).scopes).toEqual ["source.js"]
@ -419,7 +419,7 @@ describe "TokenizedBuffer", ->
describe ".bufferRangeForScopeAtPosition(selector, position)", ->
beforeEach ->
buffer = project.bufferForPathSync('sample.js')
buffer = atom.project.bufferForPathSync('sample.js')
tokenizedBuffer = new TokenizedBuffer({buffer})
fullyTokenize(tokenizedBuffer)

View File

@ -8,8 +8,8 @@ describe "Window", ->
beforeEach ->
spyOn(atom, 'hide')
atom.getLoadSettings() # Causes atom.loadSettings to be initialized
atom.loadSettings.initialPath = project.getPath()
project.destroy()
atom.loadSettings.initialPath = atom.project.getPath()
atom.project.destroy()
windowEventHandler = new WindowEventHandler()
window.deserializeEditorWindow()
projectPath = project.getPath()
@ -61,7 +61,7 @@ describe "Window", ->
it "prompts user to save and and calls rootView.confirmClose", ->
spyOn(rootView, 'confirmClose').andCallThrough()
spyOn(atom, "confirmSync").andReturn(2)
editor = rootView.openSync("sample.js")
editor = atom.rootView.openSync("sample.js")
editor.insertText("I look different, I feel different.")
$(window).trigger(beforeUnloadEvent)
expect(rootView.confirmClose).toHaveBeenCalled()
@ -69,14 +69,14 @@ describe "Window", ->
it "prompts user to save and handler returns true if don't save", ->
spyOn(atom, "confirmSync").andReturn(2)
editor = rootView.openSync("sample.js")
editor = atom.rootView.openSync("sample.js")
editor.insertText("I look different, I feel different.")
$(window).trigger(beforeUnloadEvent)
expect(atom.confirmSync).toHaveBeenCalled()
it "prompts user to save and handler returns false if dialog is canceled", ->
spyOn(atom, "confirmSync").andReturn(1)
editor = rootView.openSync("sample.js")
editor = atom.rootView.openSync("sample.js")
editor.insertText("I look different, I feel different.")
$(window).trigger(beforeUnloadEvent)
expect(atom.confirmSync).toHaveBeenCalled()
@ -93,9 +93,9 @@ describe "Window", ->
expect(atom.saveWindowState).toHaveBeenCalled()
it "unsubscribes from all buffers", ->
rootView.openSync('sample.js')
buffer = rootView.getActivePaneItem().buffer
pane = rootView.getActivePane()
atom.rootView.openSync('sample.js')
buffer = atom.rootView.getActivePaneItem().buffer
pane = atom.rootView.getActivePane()
pane.splitRight(pane.copyActiveItem())
expect(atom.rootView.find('.editor').length).toBe 2