@@ -28,7 +28,7 @@ describe 'ProjectFindView', ->
28
28
atom .project .setPaths ([path .join (__dirname , ' fixtures' )])
29
29
jasmine .attachToDOM (workspaceElement)
30
30
31
- atom .config .set (' find-and-replace.openProjectFindResultsInRightPane ' , false )
31
+ atom .config .set (' find-and-replace.openProjectFindResultsDirection ' , ' none ' )
32
32
activationPromise = atom .packages .activatePackage (" find-and-replace" ).then (options) ->
33
33
mainModule = options .mainModule
34
34
mainModule .createViews ()
@@ -366,9 +366,22 @@ describe 'ProjectFindView', ->
366
366
workspaceElement .style .height = ' 1000px'
367
367
atom .commands .dispatch editorView, ' project-find:show'
368
368
369
- it " splits when option is true " , ->
369
+ it " splits when option is right " , ->
370
370
initialPane = atom .workspace .getActivePane ()
371
- atom .config .set (' find-and-replace.openProjectFindResultsInRightPane' , true )
371
+ atom .config .set (' find-and-replace.openProjectFindResultsDirection' , ' right' )
372
+ projectFindView .findEditor .setText (' items' )
373
+ atom .commands .dispatch (projectFindView[0 ], ' core:confirm' )
374
+
375
+ waitsForPromise ->
376
+ searchPromise
377
+
378
+ runs ->
379
+ pane1 = atom .workspace .getActivePane ()
380
+ expect (pane1).not .toBe initialPane
381
+
382
+ it " splits when option is bottom" , ->
383
+ initialPane = atom .workspace .getActivePane ()
384
+ atom .config .set (' find-and-replace.openProjectFindResultsDirection' , ' down' )
372
385
projectFindView .findEditor .setText (' items' )
373
386
atom .commands .dispatch (projectFindView[0 ], ' core:confirm' )
374
387
@@ -391,8 +404,8 @@ describe 'ProjectFindView', ->
391
404
pane1 = atom .workspace .getActivePane ()
392
405
expect (pane1).toBe initialPane
393
406
394
- it " can be duplicated" , ->
395
- atom .config .set (' find-and-replace.openProjectFindResultsInRightPane ' , true )
407
+ it " can be duplicated on the right " , ->
408
+ atom .config .set (' find-and-replace.openProjectFindResultsDirection ' , ' right ' )
396
409
projectFindView .findEditor .setText (' items' )
397
410
atom .commands .dispatch (projectFindView[0 ], ' core:confirm' )
398
411
@@ -416,6 +429,31 @@ describe 'ProjectFindView', ->
416
429
417
430
expect (resultsPaneView2 .querySelector (' .preview-count' ).innerHTML ).toEqual resultsPaneView1 .querySelector (' .preview-count' ).innerHTML
418
431
432
+ it " can be duplicated at the bottom" , ->
433
+ atom .config .set (' find-and-replace.openProjectFindResultsDirection' , ' down' )
434
+ projectFindView .findEditor .setText (' items' )
435
+ atom .commands .dispatch (projectFindView[0 ], ' core:confirm' )
436
+
437
+ waitsForPromise ->
438
+ searchPromise
439
+
440
+ runs ->
441
+ resultsPaneView1 = atom .views .getView (getExistingResultsPane ())
442
+ pane1 = atom .workspace .getActivePane ()
443
+ pane1 .splitDown (copyActiveItem : true )
444
+
445
+ pane2 = atom .workspace .getActivePane ()
446
+ resultsPaneView2 = atom .views .getView (pane2 .itemForURI (ResultsPaneView .URI ))
447
+
448
+ expect (pane1).not .toBe pane2
449
+ expect (resultsPaneView1).not .toBe resultsPaneView2
450
+
451
+ length = resultsPaneView1 .querySelectorAll (' li > ul > li' ).length
452
+ expect (length).toBeGreaterThan 0
453
+ expect (resultsPaneView2 .querySelectorAll (' li > ul > li' )).toHaveLength length
454
+
455
+ expect (resultsPaneView2 .querySelector (' .preview-count' ).innerHTML ).toEqual resultsPaneView1 .querySelector (' .preview-count' ).innerHTML
456
+
419
457
describe " serialization" , ->
420
458
it " serializes if the case, regex and whole word options" , ->
421
459
atom .commands .dispatch editorView, ' project-find:show'
@@ -1412,9 +1450,9 @@ describe 'ProjectFindView', ->
1412
1450
expect (projectFindView .pathsEditor ).not .toHaveClass (' is-focused' )
1413
1451
1414
1452
describe " panel opening" , ->
1415
- describe " when a panel is already open" , ->
1453
+ describe " when a panel is already open on the right " , ->
1416
1454
beforeEach ->
1417
- atom .config .set (' find-and-replace.openProjectFindResultsInRightPane ' , true )
1455
+ atom .config .set (' find-and-replace.openProjectFindResultsDirection ' , ' right ' )
1418
1456
1419
1457
waitsForPromise ->
1420
1458
atom .workspace .open (' sample.js' )
@@ -1445,6 +1483,39 @@ describe 'ProjectFindView', ->
1445
1483
runs ->
1446
1484
expect (workspaceElement .querySelectorAll (' .preview-pane' ).length ).toBe (1 )
1447
1485
1486
+ describe " when a panel is already open at the bottom" , ->
1487
+ beforeEach ->
1488
+ atom .config .set (' find-and-replace.openProjectFindResultsDirection' , ' down' )
1489
+
1490
+ waitsForPromise ->
1491
+ atom .workspace .open (' sample.js' )
1492
+
1493
+ runs ->
1494
+ editor = atom .workspace .getActiveTextEditor ()
1495
+ editorView = atom .views .getView (editor)
1496
+ atom .commands .dispatch (workspaceElement, ' project-find:show' )
1497
+
1498
+ waitsForPromise ->
1499
+ activationPromise
1500
+
1501
+ runs ->
1502
+ projectFindView .findEditor .setText (' items' )
1503
+ atom .commands .dispatch (projectFindView[0 ], ' core:confirm' )
1504
+
1505
+ waitsForPromise ->
1506
+ searchPromise
1507
+
1508
+ it " doesn't open another panel even if the active pane is horizontally split" , ->
1509
+ atom .commands .dispatch (editorView, ' pane:split-right' )
1510
+ projectFindView .findEditor .setText (' items' )
1511
+ atom .commands .dispatch (projectFindView[0 ], ' core:confirm' )
1512
+
1513
+ waitsForPromise ->
1514
+ searchPromise
1515
+
1516
+ runs ->
1517
+ expect (workspaceElement .querySelectorAll (' .preview-pane' ).length ).toBe (1 )
1518
+
1448
1519
describe " when language-javascript is active" , ->
1449
1520
beforeEach ->
1450
1521
waitsForPromise ->
0 commit comments