Skip to content

Commit

Permalink
Add test for calculating the orphan flag
Browse files Browse the repository at this point in the history
  • Loading branch information
csillag committed Mar 27, 2015
1 parent 41d6011 commit 3448bee
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions h/static/scripts/test/guest-test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ describe 'Annotator.Guest', ->

getHighlights: sandbox.stub().returns([])
getAnchors: sandbox.stub().returns([])
createAnchor: sandbox.spy (annotation, target) ->
anchor = "anchor for " + target
annotation.anchors.push anchor

result: anchor
}

Annotator.Plugin.CrossFrame = -> fakeCrossFrame
Expand Down Expand Up @@ -292,3 +297,24 @@ describe 'Annotator.Guest', ->
guest = createGuest()
guest.setupAnnotation({ranges: []})
assert.called(fakeCrossFrame.sync)

describe 'Annotator monkey patch', ->
describe 'setupAnnotation()', ->
it "doesn't declare annotation without targets as orphans", ->
guest = createGuest()
annotation = target: []
guest.setupAnnotation(annotation)
assert.isFalse !!annotation.$orphan

it "doesn't declare annotations with a working target as orphans", ->
guest = createGuest()
annotation = target: ["test target"]
guest.setupAnnotation(annotation)
assert.isFalse !!annotation.$orphan

it "declares annotations with broken targets as orphans", ->
guest = createGuest()
guest.anchoring.createAnchor = -> result: null
annotation = target: ["broken target"]
guest.setupAnnotation(annotation)
assert !!annotation.$orphan

0 comments on commit 3448bee

Please sign in to comment.