@@ -28,7 +28,7 @@ describe 'ProjectFindView', ->
2828 atom .project .setPaths ([path .join (__dirname , ' fixtures' )])
2929 jasmine .attachToDOM (workspaceElement)
3030
31- atom .config .set (' find-and-replace.openProjectFindResultsInRightPane ' , false )
31+ atom .config .set (' find-and-replace.openProjectFindResultsDirection ' , ' none ' )
3232 activationPromise = atom .packages .activatePackage (" find-and-replace" ).then (options) ->
3333 mainModule = options .mainModule
3434 mainModule .createViews ()
@@ -366,9 +366,22 @@ describe 'ProjectFindView', ->
366366 workspaceElement .style .height = ' 1000px'
367367 atom .commands .dispatch editorView, ' project-find:show'
368368
369- it " splits when option is true " , ->
369+ it " splits when option is right " , ->
370370 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' )
372385 projectFindView .findEditor .setText (' items' )
373386 atom .commands .dispatch (projectFindView[0 ], ' core:confirm' )
374387
@@ -391,8 +404,8 @@ describe 'ProjectFindView', ->
391404 pane1 = atom .workspace .getActivePane ()
392405 expect (pane1).toBe initialPane
393406
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 ' )
396409 projectFindView .findEditor .setText (' items' )
397410 atom .commands .dispatch (projectFindView[0 ], ' core:confirm' )
398411
@@ -416,6 +429,31 @@ describe 'ProjectFindView', ->
416429
417430 expect (resultsPaneView2 .querySelector (' .preview-count' ).innerHTML ).toEqual resultsPaneView1 .querySelector (' .preview-count' ).innerHTML
418431
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+
419457 describe " serialization" , ->
420458 it " serializes if the case, regex and whole word options" , ->
421459 atom .commands .dispatch editorView, ' project-find:show'
@@ -1412,9 +1450,9 @@ describe 'ProjectFindView', ->
14121450 expect (projectFindView .pathsEditor ).not .toHaveClass (' is-focused' )
14131451
14141452 describe " panel opening" , ->
1415- describe " when a panel is already open" , ->
1453+ describe " when a panel is already open on the right " , ->
14161454 beforeEach ->
1417- atom .config .set (' find-and-replace.openProjectFindResultsInRightPane ' , true )
1455+ atom .config .set (' find-and-replace.openProjectFindResultsDirection ' , ' right ' )
14181456
14191457 waitsForPromise ->
14201458 atom .workspace .open (' sample.js' )
@@ -1445,6 +1483,39 @@ describe 'ProjectFindView', ->
14451483 runs ->
14461484 expect (workspaceElement .querySelectorAll (' .preview-pane' ).length ).toBe (1 )
14471485
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+
14481519 describe " when language-javascript is active" , ->
14491520 beforeEach ->
14501521 waitsForPromise ->
0 commit comments