@@ -2,26 +2,39 @@ const CompareVisibleEditorsCommand = require('../../../lib/commands/compare-visi
22const td = require ( 'testdouble' )
33
44suite ( 'CompareVisibleEditorsCommand' , ( ) => {
5+ const editor1 = { viewColumn : 1 }
6+ const editor2 = { viewColumn : 2 }
7+
58 test ( 'it compares 2 visible editors' , async ( ) => {
6- const { command, deps} = createCommand ( [ 'EDITOR_1' , 'EDITOR_2' ] )
9+ const { command, deps } = createCommand ( [ editor1 , editor2 ] )
710 await command . execute ( )
811
912 td . verify ( deps . selectionInfoRegistry . set ( 'visible1' , 'TEXT_INFO1' ) )
1013 td . verify ( deps . selectionInfoRegistry . set ( 'visible2' , 'TEXT_INFO2' ) )
1114 td . verify ( deps . diffPresenter . takeDiff ( 'visible1' , 'visible2' ) )
1215 } )
1316
17+ test ( 'it keeps the visual order of the editors when presents a diff' , async ( ) => {
18+ const { command, deps } = createCommand ( [ editor2 , editor1 ] )
19+ await command . execute ( )
20+
21+ td . verify ( deps . selectionInfoRegistry . set ( 'visible1' , 'TEXT_INFO1' ) )
22+ td . verify ( deps . selectionInfoRegistry . set ( 'visible2' , 'TEXT_INFO2' ) )
23+ } )
24+
1425 test ( 'it tells you that it needs 2 visible editors' , async ( ) => {
15- const { command, deps} = createCommand ( [ 'EDITOR_1' ] )
26+ const { command, deps } = createCommand ( [ editor1 ] )
1627 await command . execute ( )
1728
18- td . verify ( deps . messageBar . showInfo ( 'Please first open 2 documents to compare.' ) )
29+ td . verify (
30+ deps . messageBar . showInfo ( 'Please first open 2 documents to compare.' )
31+ )
1932 } )
2033
2134 function createCommand ( visibleTextEditors ) {
2235 const selectionInfoBuilder = td . object ( [ 'extract' ] )
23- td . when ( selectionInfoBuilder . extract ( 'EDITOR_1' ) ) . thenReturn ( 'TEXT_INFO1' )
24- td . when ( selectionInfoBuilder . extract ( 'EDITOR_2' ) ) . thenReturn ( 'TEXT_INFO2' )
36+ td . when ( selectionInfoBuilder . extract ( editor1 ) ) . thenReturn ( 'TEXT_INFO1' )
37+ td . when ( selectionInfoBuilder . extract ( editor2 ) ) . thenReturn ( 'TEXT_INFO2' )
2538
2639 const dependencies = {
2740 editorWindow : { visibleTextEditors } ,
@@ -31,6 +44,6 @@ suite('CompareVisibleEditorsCommand', () => {
3144 selectionInfoRegistry : td . object ( [ 'set' ] )
3245 }
3346 const command = new CompareVisibleEditorsCommand ( dependencies )
34- return { command, deps : dependencies }
47+ return { command, deps : dependencies }
3548 }
3649} )
0 commit comments