Merge commit '0384f025dd6915d2d9771e37983dc839e49b28f7'

This commit is contained in:
Nathan Sobo
2012-07-26 14:11:29 -06:00
4 changed files with 72 additions and 2 deletions

View File

@@ -110,6 +110,27 @@ describe "Editor", ->
expect(editor.isFocused).toBeFalsy()
expect(editor).not.toHaveClass('focused')
describe "when the activeEditSession's file is modified on disk", ->
it "triggers an alert", ->
path = "/tmp/atom-changed-file.txt"
fs.write(path, "")
editSession = project.buildEditSessionForPath(path)
editor.edit(editSession)
editor.insertText("now the buffer is modified")
fileChangeHandler = jasmine.createSpy('fileChange')
editSession.buffer.file.on 'contents-change', fileChangeHandler
spyOn($native, "alert")
fs.write(path, "a file change")
waitsFor "file to trigger contents-change event", ->
fileChangeHandler.callCount > 0
runs ->
expect($native.alert).toHaveBeenCalled()
describe ".remove()", ->
it "removes subscriptions from all edit session buffers", ->
previousEditSession = editor.activeEditSession
@@ -227,6 +248,26 @@ describe "Editor", ->
editor.activeEditSession.selectToEndOfLine()
expect(editor.getSelectionView().find('.selection')).toExist()
it "triggers alert if edit session's file changed on disk", ->
path = "/tmp/atom-changed-file.txt"
fs.write(path, "")
editSession = project.buildEditSessionForPath(path)
editSession.insertText("a buffer change")
fileChangeHandler = jasmine.createSpy('fileChange')
editSession.buffer.file.on 'contents-change', fileChangeHandler
spyOn($native, "alert")
fs.write(path, "a file change")
waitsFor "file to trigger contents-change event", ->
fileChangeHandler.callCount > 0
runs ->
editor.edit(editSession)
expect($native.alert).toHaveBeenCalled()
describe ".loadNextEditSession()", ->
it "loads the next editor state and wraps to beginning when end is reached", ->
expect(editor.activeEditSession).toBe session2