Skip to content
This repository was archived by the owner on Nov 8, 2017. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/view/side-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class SideView extends CoveringView
@span class: 'pull-right', =>
@button class: 'btn btn-xs inline-block-tight revert', click: 'revert', outlet: 'revertBtn', 'Revert'
@button class: 'btn btn-xs inline-block-tight', click: 'useMe', outlet: 'useMeBtn', 'Use Me'
@button class: 'btn btn-xs inline-block-tight', click: 'useMeFirst', outlet: 'useMeFirstBtn', 'Use Me, Then Them'
@button class: 'btn btn-xs inline-block-tight', click: 'useMeLast', outlet: 'useMeLastBtn', 'Use Them, Then Me'
## TODO: Add `title` attributes to describe these actions better?

initialize: (@side, editor) ->
@subs = new CompositeDisposable
Expand Down Expand Up @@ -61,6 +64,18 @@ class SideView extends CoveringView
useMe: ->
@side.resolve()
@decorate()

useMeFirst: ->
## FIXME: Use `ConflictedEditor#acceptOursThenTheirs` instead?
## @side.resolve()
## TODO: Get the _other_ side and resolve it, too...
@decorate()

useMeLast: ->
## FIXME: Use `ConflictedEditor#acceptTheirsThenOurs` instead?
## TODO: Get the _other_ side and resolve it, too...
## @side.resolve()
@decorate()

revert: ->
@editor.setTextInBufferRange @side.marker.getBufferRange(), @side.originalText
Expand Down
22 changes: 18 additions & 4 deletions spec/view/side-view-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,24 @@ describe 'SideView', ->
expect(t).toBe("These are my changes\n")
expect(ours.isDirty).toBe(false)

it 'triggers conflict resolution', ->
spyOn(ours, "resolve")
view.useMe()
expect(ours.resolve).toHaveBeenCalled()
describe 'conflict resolution', ->
it 'should call `resolve` for simple resolutions ("Use Me")' ->
spyOn(ours, "resolve")
view.useMe()
expect(ours.resolve).toHaveBeenCalled()

describe 'complex resolutions ("Keep Both")' ->
it 'should have an instance of `ConflictedEditor`' ->
expect(ours.editor).toBeDefined()
## TODO: expect(ours.editor).toBe("ConflictedEditor")...?

it 'should call `ConflictedEditor#acceptOursThenTheirs` for "Use Me First"' ->
## TODO: Setup spy
## TODO: expect(spy).toHaveBeenCalled()

it 'should call `ConflictedEditor#acceptTheirsThenOurs` for "Use Me Last"' ->
## TODO: Setup...
## TODO: expect(spy).toHaveBeenCalled()

describe 'when chosen as the resolution', ->

Expand Down