@@ -6,6 +6,7 @@ os = require 'os'
6
6
{remote , shell } = require ' electron'
7
7
Directory = require ' ../lib/directory'
8
8
eventHelpers = require " ./event-helpers"
9
+ spyOnAsyncAndCallThrough = require (' ./async-helper' ).spyOnAsyncAndCallThrough
9
10
10
11
isCaseSensitive = null
11
12
isFilesystemCaseSensitive = ->
@@ -3133,6 +3134,54 @@ describe "TreeView", ->
3133
3134
runs ->
3134
3135
expect (atom .notifications .getNotifications ().length ).toBe 0
3135
3136
3137
+ describe " treev-view:remove-permanently" , ->
3138
+ beforeEach ->
3139
+ jasmine .attachToDOM (workspaceElement)
3140
+
3141
+ it " won't remove the root directory" , ->
3142
+ spyOn (atom, ' confirm' )
3143
+ treeView .focus ()
3144
+ root1 .dispatchEvent (new MouseEvent (' click' , {bubbles : true , detail : 1 }))
3145
+ atom .commands .dispatch (treeView .element , ' tree-view:remove-permanently' )
3146
+
3147
+ args = atom .confirm .mostRecentCall .args [0 ]
3148
+ expect (args .buttons ).toEqual [' OK' ]
3149
+
3150
+ it " shows the native alert dialog" , ->
3151
+ spyOn (atom, ' confirm' )
3152
+
3153
+ waitForWorkspaceOpenEvent ->
3154
+ fileView .dispatchEvent (new MouseEvent (' click' , {bubbles : true , detail : 1 }))
3155
+
3156
+ runs ->
3157
+ atom .commands .dispatch (treeView .element , ' tree-view:remove-permanently' )
3158
+ args = atom .confirm .mostRecentCall .args [0 ]
3159
+ expect (args .buttons ).toEqual [' Permanently Delete ⚠️' , ' Cancel' ]
3160
+
3161
+
3162
+ it " calls removeSelectedEntries and removeSelectedPathsPermanently" , ->
3163
+ spyOn (atom, ' confirm' )
3164
+
3165
+ removeSelectedPathsPermanentlySpy = spyOnAsyncAndCallThrough (treeView, ' removeSelectedPathsPermanently' )
3166
+ removeSelectedEntriesSpy = spyOn (treeView, ' removeSelectedEntries' ).andCallThrough ()
3167
+
3168
+ filePath = path .join (os .tmpdir (), ' non-project-file.txt' )
3169
+ fs .writeFileSync (filePath, ' test' )
3170
+
3171
+ waitsForPromise ->
3172
+ atom .workspace .open (filePath)
3173
+
3174
+ waitsForPromise ->
3175
+ atom .commands .dispatch (treeView .element , ' tree-view:remove-permanently' )
3176
+
3177
+ waitsFor ->
3178
+ removeSelectedPathsPermanentlySpy .calledWith isnt undefined
3179
+
3180
+ waitsFor ' removeSelectedEntries amd removeSelectedPathsPermanently to be called' , ->
3181
+ removeSelectedEntriesSpy .callCount is 1 and
3182
+ removeSelectedEntriesSpy .mostRecentCall .args [0 ] is true and
3183
+ removeSelectedPathsPermanentlySpy .calledWith [0 ] is [filePath]
3184
+
3136
3185
describe " file system events" , ->
3137
3186
temporaryFilePath = null
3138
3187
0 commit comments