mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-02 20:07:25 +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()
|
pane.saveActiveItem()
|
||||||
expect(atom.showSaveDialogSync).not.toHaveBeenCalled()
|
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()", ->
|
describe "::saveActiveItemAs()", ->
|
||||||
pane = null
|
pane = null
|
||||||
|
|
||||||
@ -404,6 +423,25 @@ describe "Pane", ->
|
|||||||
pane.saveActiveItemAs()
|
pane.saveActiveItemAs()
|
||||||
expect(atom.showSaveDialogSync).not.toHaveBeenCalled()
|
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)", ->
|
describe "::itemForURI(uri)", ->
|
||||||
it "returns the item for which a call to .getURI() returns the given 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")])
|
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)
|
newItemPath = atom.showSaveDialogSync(itemPath)
|
||||||
if newItemPath
|
if newItemPath
|
||||||
try
|
try
|
||||||
|
console.log 'here?'
|
||||||
item.saveAs(newItemPath)
|
item.saveAs(newItemPath)
|
||||||
catch error
|
catch error
|
||||||
@handleSaveError(error)
|
@handleSaveError(error)
|
||||||
|
Loading…
Reference in New Issue
Block a user