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
f0fd0897
Commit
f0fd0897
authored
Feb 20, 2015
by
csillag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Group and label single-phase tests
parent
06152dca
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
204 additions
and
193 deletions
+204
-193
enhancedanchoring-test.coffee
tests/js/plugin/enhancedanchoring-test.coffee
+204
-193
No files found.
tests/js/plugin/enhancedanchoring-test.coffee
View file @
f0fd0897
...
...
@@ -28,9 +28,26 @@ describe 'Annotator.Plugin.EnhancedAnchoring', ->
sandbox
=
null
pendingTest
=
null
watchForScroll
=
->
new
Promise
(
resolve
,
reject
)
->
pendingTest
=
resolve
:
resolve
beforeEach
->
sandbox
=
sinon
.
sandbox
.
create
()
sandbox
.
stub
Annotator
.
TextHighlight
,
'createFrom'
,
(
segment
,
anchor
,
page
)
->
segment
:
segment
anchor
:
anchor
page
:
page
removeFromDocument
:
sinon
.
spy
()
scrollToView
:
sinon
.
spy
->
pendingTest
?
.
resolve
()
afterEach
->
sandbox
.
restore
()
pendingTest
=
null
describe
"single-phase anchoring"
,
->
createTestAnnotation
=
(
id
,
targets
=
1
)
->
id
:
"annotation "
+
id
target
:
((
"target "
+
id
+
"-"
+
num
)
for
num
in
[
1
..
targets
])
anchors
:
[]
createAnchoringManager
=
->
annotator
=
...
...
@@ -51,26 +68,7 @@ describe 'Annotator.Plugin.EnhancedAnchoring', ->
am
createTestAnnotation
=
(
id
,
targets
=
1
)
->
id
:
"annotation "
+
id
target
:
((
"target "
+
id
+
"-"
+
num
)
for
num
in
[
1
..
targets
])
anchors
:
[]
beforeEach
->
sandbox
=
sinon
.
sandbox
.
create
()
sandbox
.
stub
Annotator
.
TextHighlight
,
'createFrom'
,
(
segment
,
anchor
,
page
)
->
segment
:
segment
anchor
:
anchor
page
:
page
removeFromDocument
:
sinon
.
spy
()
scrollToView
:
sinon
.
spy
->
pendingTest
?
.
resolve
()
afterEach
->
sandbox
.
restore
()
pendingTest
=
null
describe
"createAnchor"
,
->
describe
"createAnchor() - single-phase"
,
->
it
'adds an anchor property to the annotations'
,
->
am
=
createAnchoringManager
()
...
...
@@ -88,6 +86,7 @@ describe 'Annotator.Plugin.EnhancedAnchoring', ->
am
=
createAnchoringManager
()
ann
=
createTestAnnotation
"a1"
anchor
=
am
.
createAnchor
(
ann
,
ann
.
target
[
0
]).
result
assert
.
equal
anchor
.
annotation
,
ann
it
'adds a target property to the created anchors'
,
->
...
...
@@ -101,12 +100,14 @@ describe 'Annotator.Plugin.EnhancedAnchoring', ->
am
=
createAnchoringManager
()
ann
=
createTestAnnotation
"a1"
anchor
=
am
.
createAnchor
(
ann
,
ann
.
target
[
0
]).
result
assert
.
equal
anchor
.
id
,
"fake anchor for "
+
anchor
.
target
.
id
it
'adds the created anchors to the correct per-page array'
,
->
am
=
createAnchoringManager
()
ann
=
createTestAnnotation
"a1"
anchor
=
am
.
createAnchor
(
ann
,
ann
.
target
[
0
]).
result
assert
.
include
am
.
anchors
[
anchor
.
startPage
],
anchor
it
'adds the created highlights to the anchors'
,
->
...
...
@@ -115,8 +116,10 @@ describe 'Annotator.Plugin.EnhancedAnchoring', ->
anchor
=
am
.
createAnchor
(
ann
,
ann
.
target
[
0
]).
result
assert
.
isObject
anchor
.
highlight
page
=
anchor
.
startPage
hl
=
anchor
.
highlight
[
page
]
assert
.
ok
hl
assert
.
equal
hl
.
page
,
page
...
...
@@ -129,6 +132,7 @@ describe 'Annotator.Plugin.EnhancedAnchoring', ->
anchor
=
am
.
createAnchor
(
ann
,
ann
.
target
[
0
]).
result
hl
=
anchor
.
highlight
[
anchor
.
startPage
]
assert
.
calledWith
am
.
annotator
.
publish
,
'highlightsCreated'
,
[
hl
]
it
'adds an anchor property to the created Highlights'
,
->
...
...
@@ -138,9 +142,10 @@ describe 'Annotator.Plugin.EnhancedAnchoring', ->
page
=
anchor
.
startPage
hl
=
anchor
.
highlight
[
page
]
assert
.
equal
hl
.
anchor
,
anchor
describe
"getAnchors
"
,
->
describe
"getAnchors()
"
,
->
it
'returns an empty array by default'
,
->
am
=
createAnchoringManager
()
...
...
@@ -185,10 +190,11 @@ describe 'Annotator.Plugin.EnhancedAnchoring', ->
assert
.
include
anchors
,
anchor2
assert
.
notInclude
anchors
,
anchor3
describe
'getHighlights
'
,
->
describe
'getHighlights()
'
,
->
it
'returns an empty array by default'
,
->
am
=
createAnchoringManager
()
hls
=
am
.
getHighlights
()
assert
.
isArray
hls
assert
.
equal
hls
.
length
,
0
...
...
@@ -228,12 +234,13 @@ describe 'Annotator.Plugin.EnhancedAnchoring', ->
assert
.
include
hls
,
anchor2
.
highlight
[
anchor2
.
startPage
]
assert
.
notInclude
hls
,
anchor3
.
highlight
[
anchor3
.
startPage
]
describe
'Anchor.scrollToView()
'
,
->
describe
'Anchor.scrollToView() - single-phase
'
,
->
it
'calls scrollIntoView() on the highlight'
,
->
am
=
createAnchoringManager
()
ann
=
createTestAnnotation
"a1"
anchor
=
am
.
createAnchor
(
ann
,
ann
.
target
[
0
]).
result
anchor
.
scrollToView
()
assert
.
called
anchor
.
highlight
[
anchor
.
startPage
].
scrollToView
describe
'two-phased anchoring'
,
->
...
...
@@ -655,6 +662,10 @@ describe 'Annotator.Plugin.EnhancedAnchoring', ->
describe
'when scrolling to a virtual anchor'
,
->
watchForScroll
=
->
new
Promise
(
resolve
,
reject
)
->
pendingTest
=
resolve
:
resolve
it
'scrolls right next to the wanted page (to get it rendered)'
,
->
am
=
createAnchoringManagerAndLazyDocument
()
ann
=
createTestAnnotationForPages
"a1"
,
[
10
]
...
...
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