@@ -166,6 +166,49 @@ describe('EditorConflictController', function() {
166166 assert . strictEqual ( conflicts [ 2 ] . getChosenSide ( ) , conflicts [ 2 ] . getSide ( THEIRS ) ) ;
167167 } ) ;
168168
169+ it ( 'resolves multiple conflicts as "ours"' , function ( ) {
170+ assert . isFalse ( conflicts [ 0 ] . isResolved ( ) ) ;
171+ assert . isFalse ( conflicts [ 1 ] . isResolved ( ) ) ;
172+ assert . isFalse ( conflicts [ 2 ] . isResolved ( ) ) ;
173+
174+ editor . setCursorBufferPosition ( [ 8 , 3 ] ) ; // On "Your changes"
175+ editor . addCursorAtBufferPosition ( [ 11 , 2 ] ) ; // On "Text in between 0 and 1."
176+ editor . addCursorAtBufferPosition ( [ 14 , 5 ] ) ; // On "My middle changes"
177+ editor . addCursorAtBufferPosition ( [ 15 , 0 ] ) ; // On "======="
178+ commandRegistry . dispatch ( editorView , 'github:resolve-as-ours' ) ;
179+
180+ assert . isTrue ( conflicts [ 0 ] . isResolved ( ) ) ;
181+ assert . strictEqual ( conflicts [ 0 ] . getChosenSide ( ) , conflicts [ 0 ] . getSide ( OURS ) ) ;
182+ assert . deepEqual ( conflicts [ 0 ] . getUnchosenSides ( ) , [ conflicts [ 0 ] . getSide ( THEIRS ) ] ) ;
183+
184+ assert . isTrue ( conflicts [ 1 ] . isResolved ( ) ) ;
185+ assert . strictEqual ( conflicts [ 1 ] . getChosenSide ( ) , conflicts [ 1 ] . getSide ( OURS ) ) ;
186+ assert . deepEqual ( conflicts [ 1 ] . getUnchosenSides ( ) , [ conflicts [ 1 ] . getSide ( THEIRS ) ] ) ;
187+
188+ assert . isFalse ( conflicts [ 2 ] . isResolved ( ) ) ;
189+ } ) ;
190+
191+ it ( 'resolves multiple conflicts as "theirs"' , function ( ) {
192+ assert . isFalse ( conflicts [ 0 ] . isResolved ( ) ) ;
193+ assert . isFalse ( conflicts [ 1 ] . isResolved ( ) ) ;
194+ assert . isFalse ( conflicts [ 2 ] . isResolved ( ) ) ;
195+
196+ editor . setCursorBufferPosition ( [ 8 , 3 ] ) ; // On "Your changes"
197+ editor . addCursorAtBufferPosition ( [ 11 , 2 ] ) ; // On "Text in between 0 and 1."
198+ editor . addCursorAtBufferPosition ( [ 22 , 5 ] ) ; // On "More of my changes"
199+ commandRegistry . dispatch ( editorView , 'github:resolve-as-theirs' ) ;
200+
201+ assert . isTrue ( conflicts [ 0 ] . isResolved ( ) ) ;
202+ assert . strictEqual ( conflicts [ 0 ] . getChosenSide ( ) , conflicts [ 0 ] . getSide ( THEIRS ) ) ;
203+ assert . deepEqual ( conflicts [ 0 ] . getUnchosenSides ( ) , [ conflicts [ 0 ] . getSide ( OURS ) ] ) ;
204+
205+ assert . isFalse ( conflicts [ 1 ] . isResolved ( ) ) ;
206+
207+ assert . isTrue ( conflicts [ 2 ] . isResolved ( ) ) ;
208+ assert . strictEqual ( conflicts [ 2 ] . getChosenSide ( ) , conflicts [ 2 ] . getSide ( THEIRS ) ) ;
209+ assert . deepEqual ( conflicts [ 2 ] . getUnchosenSides ( ) , [ conflicts [ 2 ] . getSide ( OURS ) ] ) ;
210+ } ) ;
211+
169212 it ( 'disregards conflicts with cursors on both sides' , function ( ) {
170213 editor . setCursorBufferPosition ( [ 6 , 3 ] ) ; // On "Multi-line even"
171214 editor . addCursorAtBufferPosition ( [ 14 , 1 ] ) ; // On "My middle changes"
@@ -316,6 +359,26 @@ describe('EditorConflictController', function() {
316359
317360 await assert . async . isTrue ( refreshResolutionProgress . calledWith ( fixtureFile ) ) ;
318361 } ) ;
362+
363+ it ( 'performs a resolution from the context menu' , function ( ) {
364+ const conflict = conflicts [ 1 ] ;
365+ assert . isFalse ( conflict . isResolved ( ) ) ;
366+
367+ wrapper . find ( 'ConflictController' ) . at ( 1 ) . prop ( 'resolveAsSequence' ) ( [ OURS ] ) ;
368+
369+ assert . isTrue ( conflict . isResolved ( ) ) ;
370+ assert . strictEqual ( conflict . getChosenSide ( ) , conflict . getSide ( OURS ) ) ;
371+ } ) ;
372+
373+ it ( 'dismisses a conflict from the context menu' , function ( ) {
374+ const conflict = conflicts [ 2 ] ;
375+
376+ wrapper . find ( 'ConflictController' ) . at ( 2 ) . prop ( 'dismiss' ) ( ) ;
377+ wrapper . update ( ) ;
378+
379+ assert . lengthOf ( wrapper . find ( ConflictController ) , 2 ) ;
380+ assert . isFalse ( wrapper . find ( ConflictController ) . someWhere ( cc => cc . prop ( 'conflict' ) === conflict ) ) ;
381+ } ) ;
319382 } ) ;
320383
321384 describe ( 'on a file with 3-way diff markers' , function ( ) {
@@ -442,4 +505,12 @@ describe('EditorConflictController', function() {
442505 assert . equal ( editor . getText ( ) , 'These are my changes\nThese are your changes\n\nPast the end\n' ) ;
443506 } ) ;
444507 } ) ;
508+
509+ it ( 'cleans up its subscriptions when unmounting' , async function ( ) {
510+ await useFixture ( 'triple-2way-diff.txt' ) ;
511+ wrapper . unmount ( ) ;
512+
513+ editor . destroy ( ) ;
514+ assert . isFalse ( refreshResolutionProgress . called ) ;
515+ } ) ;
445516} ) ;
0 commit comments