Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
6a853c12
Commit
6a853c12
authored
Jun 11, 2015
by
Randall Leeds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic anchor storage tests for setupAnnotation
parent
94d622d9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
1 deletion
+31
-1
guest-test.coffee
h/static/scripts/annotator/test/guest-test.coffee
+31
-1
No files found.
h/static/scripts/annotator/test/guest-test.coffee
View file @
6a853c12
...
@@ -2,6 +2,7 @@ Promise = global.Promise ? require('es6-promise').Promise
...
@@ -2,6 +2,7 @@ Promise = global.Promise ? require('es6-promise').Promise
Annotator
=
require
(
'annotator'
)
Annotator
=
require
(
'annotator'
)
Guest
=
require
(
'../guest'
)
Guest
=
require
(
'../guest'
)
anchoring
=
require
(
'../anchoring/html'
)
anchoring
=
require
(
'../anchoring/html'
)
highlighter
=
require
(
'../highlighter'
)
assert
=
chai
.
assert
assert
=
chai
.
assert
sinon
.
assert
.
expose
(
assert
,
prefix
:
''
)
sinon
.
assert
.
expose
(
assert
,
prefix
:
''
)
...
@@ -316,7 +317,6 @@ describe 'Guest', ->
...
@@ -316,7 +317,6 @@ describe 'Guest', ->
afterEach
->
afterEach
->
document
.
body
.
removeChild
(
el
)
document
.
body
.
removeChild
(
el
)
sandbox
.
restore
()
it
"doesn't declare annotation without targets as orphans"
,
(
done
)
->
it
"doesn't declare annotation without targets as orphans"
,
(
done
)
->
guest
=
createGuest
()
guest
=
createGuest
()
...
@@ -356,3 +356,33 @@ describe 'Guest', ->
...
@@ -356,3 +356,33 @@ describe 'Guest', ->
assert
.
called
(
guest
.
plugins
.
BucketBar
.
update
)
assert
.
called
(
guest
.
plugins
.
BucketBar
.
update
)
assert
.
called
(
guest
.
plugins
.
CrossFrame
.
sync
)
assert
.
called
(
guest
.
plugins
.
CrossFrame
.
sync
)
done
()
done
()
it
'saves the anchor positions on the annotation'
,
(
done
)
->
guest
=
createGuest
()
sandbox
.
stub
(
anchoring
,
'anchor'
).
returns
(
range
)
clientRect
=
{
top
:
100
,
left
:
200
}
window
.
scrollX
=
50
window
.
scrollY
=
25
sandbox
.
stub
(
highlighter
,
'getBoundingClientRect'
).
returns
(
clientRect
)
annotation
=
guest
.
setupAnnotation
({
target
:
[{
selector
:
[]}]})
waitForSync
(
annotation
).
then
->
assert
.
equal
(
annotation
.
$anchors
.
length
,
1
)
pos
=
annotation
.
$anchors
[
0
].
pos
assert
.
equal
(
pos
.
top
,
125
)
assert
.
equal
(
pos
.
left
,
250
)
done
()
it
'adds the anchor to the "anchors" instance property"'
,
(
done
)
->
guest
=
createGuest
()
highlights
=
[
document
.
createElement
(
'span'
)]
sandbox
.
stub
(
anchoring
,
'anchor'
).
returns
(
range
)
sandbox
.
stub
(
highlighter
,
'highlightRange'
).
returns
(
highlights
)
target
=
[{
selector
:
[]}]
annotation
=
guest
.
setupAnnotation
({
target
:
[
target
]})
waitForSync
(
annotation
).
then
->
assert
.
equal
(
guest
.
anchors
.
length
,
1
)
assert
.
strictEqual
(
guest
.
anchors
[
0
].
annotation
,
annotation
)
assert
.
strictEqual
(
guest
.
anchors
[
0
].
target
,
target
)
assert
.
strictEqual
(
guest
.
anchors
[
0
].
range
,
range
)
assert
.
strictEqual
(
guest
.
anchors
[
0
].
highlights
,
highlights
)
done
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment