@@ -127,6 +127,42 @@ describe 'ProjectFindView', ->
127
127
expect (projectFindView .regexOptionButton ).toHaveClass ' selected'
128
128
expect (projectFindView .wholeWordOptionButton ).toHaveClass ' selected'
129
129
130
+ describe " when project-find:show-in-current-directory is triggered with an open buffer" , ->
131
+ editor = null
132
+
133
+ beforeEach ->
134
+ atom .project .setPaths ([__dirname ])
135
+ atom .commands .dispatch (workspaceElement, ' project-find:show' )
136
+
137
+ waitsForPromise ->
138
+ activationPromise
139
+
140
+ runs ->
141
+ projectFindView .findEditor .setText (' ' )
142
+ projectFindView .pathsEditor .setText (' ' )
143
+
144
+ waitsForPromise ->
145
+ atom .workspace .open (' fixtures/sample.js' ).then (o) -> editor = o
146
+
147
+ it " calls project-find:show, and populates both findEditor and pathsEditor when there is a selection" , ->
148
+ editor .setSelectedBufferRange ([[3 , 8 ], [3 , 13 ]])
149
+ atom .commands .dispatch (workspaceElement, ' project-find:show-in-current-directory' )
150
+ expect (getAtomPanel ()).toBeVisible ()
151
+ expect (projectFindView .findEditor .getText ()).toBe (' pivot' )
152
+ expect (projectFindView .pathsEditor .getText ()).toBe (' fixtures' )
153
+
154
+ editor .setSelectedBufferRange ([[2 , 14 ], [2 , 20 ]])
155
+ atom .commands .dispatch (workspaceElement, ' project-find:show-in-current-directory' )
156
+ expect (getAtomPanel ()).toBeVisible ()
157
+ expect (projectFindView .findEditor .getText ()).toBe (' length' )
158
+ expect (projectFindView .pathsEditor .getText ()).toBe (' fixtures' )
159
+
160
+ it " calls project-find:show, and populates only pathsEditor when there is no selection" , ->
161
+ atom .commands .dispatch (workspaceElement, ' project-find:show-in-current-directory' )
162
+ expect (getAtomPanel ()).toBeVisible ()
163
+ expect (projectFindView .findEditor .getText ()).toBe (' ' )
164
+ expect (projectFindView .pathsEditor .getText ()).toBe (' fixtures' )
165
+
130
166
describe " when project-find:toggle is triggered" , ->
131
167
it " toggles the visibility of the ProjectFindView" , ->
132
168
atom .commands .dispatch (workspaceElement, ' project-find:toggle' )
0 commit comments