Commit ef0214a6 authored by Randall Leeds's avatar Randall Leeds

Fix tests for promise-returning anchoring contract

parent 91a81fdd
...@@ -330,7 +330,7 @@ describe 'Guest', -> ...@@ -330,7 +330,7 @@ describe 'Guest', ->
it "doesn't declare annotations with a working target as orphans", (done) -> it "doesn't declare annotations with a working target as orphans", (done) ->
guest = createGuest() guest = createGuest()
annotation = target: [{selector: "test"}] annotation = target: [{selector: "test"}]
sandbox.stub(anchoring, 'anchor').returns(range) sandbox.stub(anchoring, 'anchor').returns(Promise.resolve(range))
guest.setupAnnotation(annotation) guest.setupAnnotation(annotation)
waitForSync(annotation).then -> waitForSync(annotation).then ->
assert.isFalse(annotation.$orphan) assert.isFalse(annotation.$orphan)
...@@ -339,7 +339,7 @@ describe 'Guest', -> ...@@ -339,7 +339,7 @@ describe 'Guest', ->
it "declares annotations with broken targets as orphans", (done) -> it "declares annotations with broken targets as orphans", (done) ->
guest = createGuest() guest = createGuest()
annotation = target: [{selector: 'broken selector'}] annotation = target: [{selector: 'broken selector'}]
sandbox.stub(anchoring, 'anchor').throws() sandbox.stub(anchoring, 'anchor').returns(Promise.reject())
guest.setupAnnotation(annotation) guest.setupAnnotation(annotation)
waitForSync(annotation).then -> waitForSync(annotation).then ->
assert.isTrue(annotation.$orphan) assert.isTrue(annotation.$orphan)
...@@ -360,7 +360,7 @@ describe 'Guest', -> ...@@ -360,7 +360,7 @@ describe 'Guest', ->
it 'saves the anchor positions on the annotation', (done) -> it 'saves the anchor positions on the annotation', (done) ->
guest = createGuest() guest = createGuest()
sandbox.stub(anchoring, 'anchor').returns(range) sandbox.stub(anchoring, 'anchor').returns(Promise.resolve(range))
clientRect = {top: 100, left: 200} clientRect = {top: 100, left: 200}
window.scrollX = 50 window.scrollX = 50
window.scrollY = 25 window.scrollY = 25
...@@ -376,7 +376,7 @@ describe 'Guest', -> ...@@ -376,7 +376,7 @@ describe 'Guest', ->
it 'adds the anchor to the "anchors" instance property"', (done) -> it 'adds the anchor to the "anchors" instance property"', (done) ->
guest = createGuest() guest = createGuest()
highlights = [document.createElement('span')] highlights = [document.createElement('span')]
sandbox.stub(anchoring, 'anchor').returns(range) sandbox.stub(anchoring, 'anchor').returns(Promise.resolve(range))
sandbox.stub(highlighter, 'highlightRange').returns(highlights) sandbox.stub(highlighter, 'highlightRange').returns(highlights)
target = [{selector: []}] target = [{selector: []}]
annotation = guest.setupAnnotation({target: [target]}) annotation = guest.setupAnnotation({target: [target]})
...@@ -404,7 +404,7 @@ describe 'Guest', -> ...@@ -404,7 +404,7 @@ describe 'Guest', ->
it 'does not reanchor targets that are already anchored', (done) -> it 'does not reanchor targets that are already anchored', (done) ->
guest = createGuest() guest = createGuest()
annotation = target: [{selector: "test"}] annotation = target: [{selector: "test"}]
stub = sandbox.stub(anchoring, 'anchor').returns(range) stub = sandbox.stub(anchoring, 'anchor').returns(Promise.resolve(range))
guest.setupAnnotation(annotation) guest.setupAnnotation(annotation)
waitForSync(annotation).then -> waitForSync(annotation).then ->
delete annotation.$anchors delete annotation.$anchors
......
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