@@ -257,44 +257,44 @@ describe('ResultsView', () => {
257
257
} ) ;
258
258
259
259
describe ( "core:move-to-top and core:move-to-bottom" , ( ) => {
260
- beforeEach ( async ( ) => {
261
- workspaceElement . style . height = '300px' ;
262
- projectFindView . findEditor . setText ( 'so' ) ;
263
- projectFindView . confirm ( ) ;
264
- await searchPromise ;
265
- resultsView = getResultsView ( ) ;
266
- } ) ;
260
+ beforeEach ( async ( ) => {
261
+ workspaceElement . style . height = '300px' ;
262
+ projectFindView . findEditor . setText ( 'so' ) ;
263
+ projectFindView . confirm ( ) ;
264
+ await searchPromise ;
265
+ resultsView = getResultsView ( ) ;
266
+ } ) ;
267
267
268
- it ( "selects the first/last item when core:move-to-top/move-to-bottom is triggered" , async ( ) => {
269
- const { listView} = resultsView . refs ;
270
- expect ( listView . element . querySelectorAll ( 'li' ) . length ) . toBeLessThan ( resultsView . model . getPathCount ( ) + resultsView . model . getMatchCount ( ) ) ;
268
+ it ( "selects the first/last item when core:move-to-top/move-to-bottom is triggered" , async ( ) => {
269
+ const { listView} = resultsView . refs ;
270
+ expect ( listView . element . querySelectorAll ( 'li' ) . length ) . toBeLessThan ( resultsView . model . getPathCount ( ) + resultsView . model . getMatchCount ( ) ) ;
271
271
272
- await resultsView . moveToBottom ( ) ;
273
- expect ( listView . element . querySelectorAll ( 'li' ) [ 1 ] ) . not . toHaveClass ( 'selected' ) ;
274
- expect ( _ . last ( listView . element . querySelectorAll ( 'li' ) ) ) . toHaveClass ( 'selected' ) ;
275
- expect ( listView . element . scrollTop ) . not . toBe ( 0 ) ;
272
+ await resultsView . moveToBottom ( ) ;
273
+ expect ( listView . element . querySelectorAll ( 'li' ) [ 1 ] ) . not . toHaveClass ( 'selected' ) ;
274
+ expect ( _ . last ( listView . element . querySelectorAll ( 'li' ) ) ) . toHaveClass ( 'selected' ) ;
275
+ expect ( listView . element . scrollTop ) . not . toBe ( 0 ) ;
276
276
277
- await resultsView . moveToTop ( ) ;
278
- expect ( listView . element . querySelector ( '.match-line' ) ) . toHaveClass ( 'selected' ) ;
279
- expect ( listView . element . scrollTop ) . toBe ( 0 ) ;
280
- } ) ;
277
+ await resultsView . moveToTop ( ) ;
278
+ expect ( listView . element . querySelector ( '.match-line' ) ) . toHaveClass ( 'selected' ) ;
279
+ expect ( listView . element . scrollTop ) . toBe ( 0 ) ;
280
+ } ) ;
281
281
282
- it ( "selects the path when when core:move-to-bottom is triggered and last item is collapsed" , async ( ) => {
283
- await resultsView . moveToBottom ( ) ;
284
- resultsView . collapseResult ( ) ;
285
- await resultsView . moveToBottom ( ) ;
282
+ it ( "selects the path when when core:move-to-bottom is triggered and last item is collapsed" , async ( ) => {
283
+ await resultsView . moveToBottom ( ) ;
284
+ resultsView . collapseResult ( ) ;
285
+ await resultsView . moveToBottom ( ) ;
286
286
287
- expect ( _ . last ( resultsView . element . querySelectorAll ( 'li' ) ) . closest ( '.path' ) ) . toHaveClass ( 'selected' ) ;
288
- } ) ;
287
+ expect ( _ . last ( resultsView . element . querySelectorAll ( 'li' ) ) . closest ( '.path' ) ) . toHaveClass ( 'selected' ) ;
288
+ } ) ;
289
289
290
- it ( "selects the path when when core:move-to-top is triggered and first item is collapsed" , async ( ) => {
291
- await resultsView . moveToTop ( ) ;
292
- atom . commands . dispatch ( resultsView . element , 'core:move-left' ) ;
293
- await resultsView . moveToTop ( ) ;
290
+ it ( "selects the path when when core:move-to-top is triggered and first item is collapsed" , async ( ) => {
291
+ await resultsView . moveToTop ( ) ;
292
+ atom . commands . dispatch ( resultsView . element , 'core:move-left' ) ;
293
+ await resultsView . moveToTop ( ) ;
294
294
295
- expect ( resultsView . refs . listView . element . querySelector ( 'li' ) . closest ( '.path' ) ) . toHaveClass ( 'selected' ) ;
296
- } ) ;
295
+ expect ( resultsView . refs . listView . element . querySelector ( 'li' ) . closest ( '.path' ) ) . toHaveClass ( 'selected' ) ;
297
296
} ) ;
297
+ } ) ;
298
298
299
299
describe ( "expanding and collapsing results" , ( ) => {
300
300
it ( 'preserves the selected file when collapsing all results' , async ( ) => {
@@ -424,41 +424,32 @@ describe('ResultsView', () => {
424
424
expect ( atom . views . getView ( editor ) ) . toHaveFocus ( ) ;
425
425
} )
426
426
427
- describe ( "when `projectSearchResultsPaneSplitDirection` option is none " , ( ) => {
427
+ describe ( "the `projectSearchResultsPaneSplitDirection` option" , ( ) => {
428
428
beforeEach ( ( ) => {
429
- atom . config . set ( 'find-and-replace.projectSearchResultsPaneSplitDirection' , 'none' ) ;
429
+ spyOn ( atom . workspace , 'open' ) . andCallThrough ( )
430
430
} ) ;
431
431
432
- it ( "does not specify a pane to split" , ( ) => {
433
- spyOn ( atom . workspace , 'open' ) . andCallThrough ( ) ;
432
+ it ( "does not create a split when the option is 'none'" , async ( ) => {
433
+ atom . config . set ( 'find-and-replace.projectSearchResultsPaneSplitDirection' , 'none' ) ;
434
434
atom . commands . dispatch ( resultsView . element , 'core:move-down' ) ;
435
435
atom . commands . dispatch ( resultsView . element , 'core:confirm' ) ;
436
+ await paneItemOpening ( )
436
437
expect ( atom . workspace . open . mostRecentCall . args [ 1 ] . split ) . toBeUndefined ( ) ;
437
438
} ) ;
438
- } ) ;
439
439
440
- describe ( "when `projectSearchResultsPaneSplitDirection` option is right" , ( ) => {
441
- beforeEach ( ( ) => {
440
+ it ( "always opens the file in the left pane when the option is 'right'" , async ( ) => {
442
441
atom . config . set ( 'find-and-replace.projectSearchResultsPaneSplitDirection' , 'right' ) ;
443
- } ) ;
444
-
445
- it ( "always opens the file in the left pane" , ( ) => {
446
- spyOn ( atom . workspace , 'open' ) . andCallThrough ( ) ;
447
442
atom . commands . dispatch ( resultsView . element , 'core:move-down' ) ;
448
443
atom . commands . dispatch ( resultsView . element , 'core:confirm' ) ;
444
+ await paneItemOpening ( )
449
445
expect ( atom . workspace . open . mostRecentCall . args [ 1 ] . split ) . toBe ( 'left' ) ;
450
446
} ) ;
451
- } ) ;
452
447
453
- describe ( "when `projectSearchResultsPaneSplitDirection` option is down" , ( ) => {
454
- beforeEach ( ( ) => {
448
+ it ( "always opens the file in the pane above when the options is 'down'" , async ( ) => {
455
449
atom . config . set ( 'find-and-replace.projectSearchResultsPaneSplitDirection' , 'down' )
456
- } ) ;
457
-
458
- it ( "always opens the file in the up pane" , ( ) => {
459
- spyOn ( atom . workspace , 'open' ) . andCallThrough ( ) ;
460
450
atom . commands . dispatch ( resultsView . element , 'core:move-down' ) ;
461
451
atom . commands . dispatch ( resultsView . element , 'core:confirm' ) ;
452
+ await paneItemOpening ( )
462
453
expect ( atom . workspace . open . mostRecentCall . args [ 1 ] . split ) . toBe ( 'up' ) ;
463
454
} ) ;
464
455
} ) ;
0 commit comments