mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-12-31 02:28:11 +03:00
Add specs for save/saveAs error handling
This commit is contained in:
parent
63ee46023d
commit
e51c8f3407
@ -383,6 +383,25 @@ describe "Pane", ->
|
||||
pane.saveActiveItem()
|
||||
expect(atom.showSaveDialogSync).not.toHaveBeenCalled()
|
||||
|
||||
describe "when the item's saveAs method throws a well-known IO error", ->
|
||||
notificationSpy = null
|
||||
beforeEach ->
|
||||
atom.notifications.onDidAddNotification notificationSpy = jasmine.createSpy()
|
||||
|
||||
it "creates a notification", ->
|
||||
pane.getActiveItem().saveAs = ->
|
||||
error = new Error("EACCES, permission denied '/foo'")
|
||||
error.path = '/foo'
|
||||
error.code = 'EACCES'
|
||||
throw error
|
||||
|
||||
pane.saveActiveItem()
|
||||
expect(notificationSpy).toHaveBeenCalled()
|
||||
notification = notificationSpy.mostRecentCall.args[0]
|
||||
expect(notification.getType()).toBe 'warning'
|
||||
expect(notification.getMessage()).toContain 'Permission denied'
|
||||
expect(notification.getMessage()).toContain '/foo'
|
||||
|
||||
describe "::saveActiveItemAs()", ->
|
||||
pane = null
|
||||
|
||||
@ -404,6 +423,25 @@ describe "Pane", ->
|
||||
pane.saveActiveItemAs()
|
||||
expect(atom.showSaveDialogSync).not.toHaveBeenCalled()
|
||||
|
||||
describe "when the item's saveAs method throws a well-known IO error", ->
|
||||
notificationSpy = null
|
||||
beforeEach ->
|
||||
atom.notifications.onDidAddNotification notificationSpy = jasmine.createSpy()
|
||||
|
||||
it "creates a notification", ->
|
||||
pane.getActiveItem().saveAs = ->
|
||||
error = new Error("EACCES, permission denied '/foo'")
|
||||
error.path = '/foo'
|
||||
error.code = 'EACCES'
|
||||
throw error
|
||||
|
||||
pane.saveActiveItemAs()
|
||||
expect(notificationSpy).toHaveBeenCalled()
|
||||
notification = notificationSpy.mostRecentCall.args[0]
|
||||
expect(notification.getType()).toBe 'warning'
|
||||
expect(notification.getMessage()).toContain 'Permission denied'
|
||||
expect(notification.getMessage()).toContain '/foo'
|
||||
|
||||
describe "::itemForURI(uri)", ->
|
||||
it "returns the item for which a call to .getURI() returns the given uri", ->
|
||||
pane = new Pane(items: [new Item("A"), new Item("B"), new Item("C"), new Item("D")])
|
||||
|
@ -502,6 +502,7 @@ class Pane extends Model
|
||||
newItemPath = atom.showSaveDialogSync(itemPath)
|
||||
if newItemPath
|
||||
try
|
||||
console.log 'here?'
|
||||
item.saveAs(newItemPath)
|
||||
catch error
|
||||
@handleSaveError(error)
|
||||
|
Loading…
Reference in New Issue
Block a user