@@ -27,7 +27,7 @@ describe 'ProjectFindView', ->
2727 atom .project .setPaths ([path .join (__dirname , ' fixtures' )])
2828 jasmine .attachToDOM (workspaceElement)
2929
30- atom .config .set (' find-and-replace.openProjectFindResultsInRightPane ' , false )
30+ atom .config .set (' find-and-replace.openProjectFindResultsInANewPane ' , ' no ' )
3131 activationPromise = atom .packages .activatePackage (" find-and-replace" ).then (options) ->
3232 mainModule = options .mainModule
3333 mainModule .createViews ()
@@ -329,9 +329,22 @@ describe 'ProjectFindView', ->
329329 workspaceElement .style .height = ' 1000px'
330330 atom .commands .dispatch editorView, ' project-find:show'
331331
332- it " splits when option is true " , ->
332+ it " splits when option is right " , ->
333333 initialPane = atom .workspace .getActivePane ()
334- atom .config .set (' find-and-replace.openProjectFindResultsInRightPane' , true )
334+ atom .config .set (' find-and-replace.openProjectFindResultsInANewPane' , ' right pane' )
335+ projectFindView .findEditor .setText (' items' )
336+ atom .commands .dispatch (projectFindView[0 ], ' core:confirm' )
337+
338+ waitsForPromise ->
339+ searchPromise
340+
341+ runs ->
342+ pane1 = atom .workspace .getActivePane ()
343+ expect (pane1).not .toBe initialPane
344+
345+ it " splits when option is bottom" , ->
346+ initialPane = atom .workspace .getActivePane ()
347+ atom .config .set (' find-and-replace.openProjectFindResultsInANewPane' , ' bottom pane' )
335348 projectFindView .findEditor .setText (' items' )
336349 atom .commands .dispatch (projectFindView[0 ], ' core:confirm' )
337350
@@ -354,8 +367,8 @@ describe 'ProjectFindView', ->
354367 pane1 = atom .workspace .getActivePane ()
355368 expect (pane1).toBe initialPane
356369
357- it " can be duplicated" , ->
358- atom .config .set (' find-and-replace.openProjectFindResultsInRightPane ' , true )
370+ it " can be duplicated on the right " , ->
371+ atom .config .set (' find-and-replace.openProjectFindResultsInANewPane ' , ' right pane ' )
359372 projectFindView .findEditor .setText (' items' )
360373 atom .commands .dispatch (projectFindView[0 ], ' core:confirm' )
361374
@@ -379,6 +392,31 @@ describe 'ProjectFindView', ->
379392
380393 expect (resultsPaneView2 .querySelector (' .preview-count' ).innerHTML ).toEqual resultsPaneView1 .querySelector (' .preview-count' ).innerHTML
381394
395+ it " can be duplicated at the bottom" , ->
396+ atom .config .set (' find-and-replace.openProjectFindResultsInANewPane' , ' bottom pane' )
397+ projectFindView .findEditor .setText (' items' )
398+ atom .commands .dispatch (projectFindView[0 ], ' core:confirm' )
399+
400+ waitsForPromise ->
401+ searchPromise
402+
403+ runs ->
404+ resultsPaneView1 = atom .views .getView (getExistingResultsPane ())
405+ pane1 = atom .workspace .getActivePane ()
406+ pane1 .splitDown (copyActiveItem : true )
407+
408+ pane2 = atom .workspace .getActivePane ()
409+ resultsPaneView2 = atom .views .getView (pane2 .itemForURI (ResultsPaneView .URI ))
410+
411+ expect (pane1).not .toBe pane2
412+ expect (resultsPaneView1).not .toBe resultsPaneView2
413+
414+ length = resultsPaneView1 .querySelectorAll (' li > ul > li' ).length
415+ expect (length).toBeGreaterThan 0
416+ expect (resultsPaneView2 .querySelectorAll (' li > ul > li' )).toHaveLength length
417+
418+ expect (resultsPaneView2 .querySelector (' .preview-count' ).innerHTML ).toEqual resultsPaneView1 .querySelector (' .preview-count' ).innerHTML
419+
382420 describe " serialization" , ->
383421 it " serializes if the case, regex and whole word options" , ->
384422 atom .commands .dispatch editorView, ' project-find:show'
@@ -1375,9 +1413,9 @@ describe 'ProjectFindView', ->
13751413 expect (projectFindView .pathsEditor ).not .toHaveClass (' is-focused' )
13761414
13771415 describe " panel opening" , ->
1378- describe " when a panel is already open" , ->
1416+ describe " when a panel is already open on the right " , ->
13791417 beforeEach ->
1380- atom .config .set (' find-and-replace.openProjectFindResultsInRightPane ' , true )
1418+ atom .config .set (' find-and-replace.openProjectFindResultsInANewPane ' , ' right pane ' )
13811419
13821420 waitsForPromise ->
13831421 atom .workspace .open (' sample.js' )
@@ -1408,6 +1446,39 @@ describe 'ProjectFindView', ->
14081446 runs ->
14091447 expect (workspaceElement .querySelectorAll (' .preview-pane' ).length ).toBe (1 )
14101448
1449+ describe " when a panel is already open at the bottom" , ->
1450+ beforeEach ->
1451+ atom .config .set (' find-and-replace.openProjectFindResultsInANewPane' , ' bottom pane' )
1452+
1453+ waitsForPromise ->
1454+ atom .workspace .open (' sample.js' )
1455+
1456+ runs ->
1457+ editor = atom .workspace .getActiveTextEditor ()
1458+ editorView = atom .views .getView (editor)
1459+ atom .commands .dispatch (workspaceElement, ' project-find:show' )
1460+
1461+ waitsForPromise ->
1462+ activationPromise
1463+
1464+ runs ->
1465+ projectFindView .findEditor .setText (' items' )
1466+ atom .commands .dispatch (projectFindView[0 ], ' core:confirm' )
1467+
1468+ waitsForPromise ->
1469+ searchPromise
1470+
1471+ it " doesn't open another panel even if the active pane is horizontally split" , ->
1472+ atom .commands .dispatch (editorView, ' pane:split-right' )
1473+ projectFindView .findEditor .setText (' items' )
1474+ atom .commands .dispatch (projectFindView[0 ], ' core:confirm' )
1475+
1476+ waitsForPromise ->
1477+ searchPromise
1478+
1479+ runs ->
1480+ expect (workspaceElement .querySelectorAll (' .preview-pane' ).length ).toBe (1 )
1481+
14111482 describe " when language-javascript is active" , ->
14121483 beforeEach ->
14131484 waitsForPromise ->
0 commit comments