Commit 570e9c2f authored by csillag's avatar csillag

Restore visual diff to original behavior

This restores the following corner case:

When there is a difference, but it's only about
the case of the characters, don't want to show
the visual diff by default, but we offer the
feature to the user.

I also updated the tests the reflect the specs.
parent e10da472
......@@ -217,11 +217,16 @@ AnnotationController = [
# Calculate the visual diff flags
@hasDiff = false
for t in @annotation.target or []
if t.diffHTML? and not t.diffCaseOnly
if t.diffHTML?
@hasDiff = t.hasDiff = true
unless t.diffCaseOnly
@showDiff ?= true
else
t.hasDiff = false
@showDiff ?= @hasDiff or undefined
if @hasDiff
@showDiff ?= false
else
@showDiff ?= undefined
updateTimestamp = (repeat=false) =>
@timestamp = timeHelpers.toFuzzyString model.updated
......
......@@ -151,12 +151,10 @@ describe 'h.directives.annotation', ->
it 'sets `showDiff` to true', ->
assert.isTrue(controller.showDiff)
it 'sets `hasDiff` to true on targets with differences', ->
it 'sets `hasDiff` to true on targets with any differences', ->
assert.isFalse(targets[0].hasDiff)
assert.isTrue(targets[1].hasDiff)
it 'sets `hasDiff` to false on targets with only case differences', ->
assert.isFalse(targets[2].hasDiff)
assert.isTrue(targets[2].hasDiff)
it 'preserves the `showDiff` value on update', ->
controller.showDiff = false
......@@ -169,6 +167,34 @@ describe 'h.directives.annotation', ->
controller.render()
assert.isFalse(controller.hasDiff)
describe 'when targets have almost the same selection text from the anchor', ->
targets = null
beforeEach ->
annotation.target = [
{otherProperty: 'bar'},
{diffHTML: "stuff", diffCaseOnly: true},
]
controller.render()
targets = controller.annotation.target
it 'sets `hasDiff` to true', ->
assert.isTrue(controller.hasDiff)
it 'sets `showDiff` to false', ->
assert.isFalse(controller.showDiff)
it 'preserves the `showDiff` value on update', ->
controller.showDiff = true
annotation.target = annotation.target.slice(1)
controller.render()
assert.isTrue(controller.showDiff)
it 'unsets `hasDiff` if differences go away', ->
annotation.target = annotation.target.splice(0, 1)
controller.render()
assert.isFalse(controller.hasDiff)
describe 'timestamp', ->
clock = null
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment