@@ -942,25 +942,6 @@ describe "TreeView", ->
942
942
_ .times entryCount, -> atom .commands .dispatch (treeView .element , ' core:move-up' )
943
943
expect (treeView .scrollTop ()).toBe 0
944
944
945
- describe " tree-view:expand-directory" , ->
946
- describe " when a directory entry is selected" , ->
947
- it " expands the current directory" , ->
948
- subdir = root1 .find (' .directory:first' )
949
- subdir .click ()
950
- subdir[0 ].collapse ()
951
-
952
- expect (subdir).not .toHaveClass ' expanded'
953
- atom .commands .dispatch (treeView .element , ' tree-view:expand-directory' )
954
- expect (subdir).toHaveClass ' expanded'
955
-
956
- describe " when a file entry is selected" , ->
957
- it " does nothing" , ->
958
- waitsForFileToOpen ->
959
- root1 .find (' .file' ).click ()
960
-
961
- runs ->
962
- atom .commands .dispatch (treeView .element , ' tree-view:expand-directory' )
963
-
964
945
describe " tree-view:recursive-expand-directory" , ->
965
946
describe " when an collapsed root is recursively expanded" , ->
966
947
it " expands the root and all subdirectories" , ->
@@ -1056,8 +1037,8 @@ describe "TreeView", ->
1056
1037
it " opens the file in the editor and focuses it" , ->
1057
1038
jasmine .attachToDOM (workspaceElement)
1058
1039
1059
- waitsForFileToOpen ->
1060
- root1 . find ( ' . file:contains(tree-view.js) ' ). click ( )
1040
+ file = root1 . find ( ' .file:contains(tree-view.js) ' )[ 0 ]
1041
+ treeView . selectEntry ( file)
1061
1042
1062
1043
waitsForFileToOpen ->
1063
1044
atom .commands .dispatch (treeView .element , ' tree-view:open-selected-entry' )
@@ -1066,6 +1047,36 @@ describe "TreeView", ->
1066
1047
item = atom .workspace .getActivePaneItem ()
1067
1048
expect (item .getPath ()).toBe atom .project .getDirectories ()[0 ].resolve (' tree-view.js' )
1068
1049
expect (atom .views .getView (item)).toHaveFocus ()
1050
+ if atom .workspace .buildTextEditor ().isPending ?
1051
+ expect (item .isPending ()).toBe false
1052
+
1053
+ if atom .workspace .buildTextEditor ().isPending ?
1054
+ it " terminates pending state for items that are pending" , ->
1055
+ jasmine .attachToDOM (workspaceElement)
1056
+
1057
+ file = root1 .find (' .file:contains(tree-view.js)' )[0 ]
1058
+ treeView .selectEntry (file)
1059
+
1060
+ waitsForFileToOpen ->
1061
+ atom .commands .dispatch (treeView .element , ' tree-view:expand-item' )
1062
+
1063
+ runs ->
1064
+ item = atom .workspace .getActivePaneItem ()
1065
+ expect (item .getPath ()).toBe atom .project .getDirectories ()[0 ].resolve (' tree-view.js' )
1066
+ expect (item .isPending ()).toBe true
1067
+ expect (atom .views .getView (item)).toHaveFocus ()
1068
+
1069
+ file = root1 .find (' .file:contains(tree-view.js)' )[0 ]
1070
+ treeView .selectEntry (file)
1071
+
1072
+ waitsForFileToOpen ->
1073
+ atom .commands .dispatch (treeView .element , ' tree-view:open-selected-entry' )
1074
+
1075
+ runs ->
1076
+ item = atom .workspace .getActivePaneItem ()
1077
+ expect (item .getPath ()).toBe atom .project .getDirectories ()[0 ].resolve (' tree-view.js' )
1078
+ expect (atom .views .getView (item)).toHaveFocus ()
1079
+ expect (item .isPending ()).toBe false
1069
1080
1070
1081
describe " when a directory is selected" , ->
1071
1082
it " expands or collapses the directory" , ->
@@ -1132,6 +1143,39 @@ describe "TreeView", ->
1132
1143
atom .commands .dispatch (treeView .element , command)
1133
1144
expect (atom .workspace .getActivePaneItem ()).toBeUndefined ()
1134
1145
1146
+ describe " tree-view:expand-item" , ->
1147
+ describe " when a file is selected" , ->
1148
+ it " opens the file in the editor in pending state and focuses it" , ->
1149
+ jasmine .attachToDOM (workspaceElement)
1150
+
1151
+ file = root1 .find (' .file:contains(tree-view.js)' )[0 ]
1152
+ treeView .selectEntry (file)
1153
+
1154
+ waitsForFileToOpen ->
1155
+ atom .commands .dispatch (treeView .element , ' tree-view:expand-item' )
1156
+
1157
+ runs ->
1158
+ item = atom .workspace .getActivePaneItem ()
1159
+ expect (item .getPath ()).toBe atom .project .getDirectories ()[0 ].resolve (' tree-view.js' )
1160
+ if atom .workspace .buildTextEditor ().isPending ?
1161
+ expect (item .isPending ()).toBe true
1162
+ expect (atom .views .getView (item)).toHaveFocus ()
1163
+
1164
+ describe " when a directory is selected" , ->
1165
+ it " expands the directory" , ->
1166
+ subdir = root1 .find (' .directory' ).first ()
1167
+ subdir .click ()
1168
+ subdir[0 ].collapse ()
1169
+
1170
+ expect (subdir).not .toHaveClass ' expanded'
1171
+ atom .commands .dispatch (treeView .element , ' tree-view:expand-item' )
1172
+ expect (subdir).toHaveClass ' expanded'
1173
+
1174
+ describe " when nothing is selected" , ->
1175
+ it " does nothing" , ->
1176
+ atom .commands .dispatch (treeView .element , ' tree-view:expand-item' )
1177
+ expect (atom .workspace .getActivePaneItem ()).toBeUndefined ()
1178
+
1135
1179
describe " opening in existing split panes" , ->
1136
1180
beforeEach ->
1137
1181
jasmine .attachToDOM (workspaceElement)
0 commit comments