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
cde59e0a
Commit
cde59e0a
authored
Feb 17, 2015
by
csillag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify test cases
parent
2fbae287
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
16 deletions
+11
-16
texthighlight-test.coffee
tests/js/plugin/texthighlight-test.coffee
+11
-16
No files found.
tests/js/plugin/texthighlight-test.coffee
View file @
cde59e0a
...
...
@@ -10,7 +10,6 @@ th.pluginInit()
describe
'Annotator.Plugin.TextHighlight'
,
->
sandbox
=
null
jqElement
=
null
scrollTarget
=
null
createTestHighlight
=
->
...
...
@@ -29,15 +28,14 @@ describe 'Annotator.Plugin.TextHighlight', ->
beforeEach
->
sandbox
=
sinon
.
sandbox
.
create
()
sandbox
.
stub
Annotator
.
TextHighlight
,
'highlightRange'
,
(
normedRange
,
cssClass
)
->
"test highlight span"
(
normedRange
,
cssClass
)
->
hl
=
document
.
createElement
"hl"
hl
.
appendChild
document
.
createTextNode
"test highlight span"
hl
sandbox
.
stub
Annotator
.
$
.
fn
,
"init"
,
(
selector
,
context
)
->
jqElement
=
selector
:
selector
data
:
sinon
.
spy
()
scrollintoview
:
sinon
.
spy
(
options
)
->
scrollTarget
=
this
.
selector
options
?
.
complete
?
()
Annotator
.
$
.
fn
.
scrollintoview
=
sinon
.
spy
(
options
)
->
scrollTarget
=
this
[
0
]
options
?
.
complete
?
()
afterEach
->
sandbox
.
restore
()
...
...
@@ -50,22 +48,19 @@ describe 'Annotator.Plugin.TextHighlight', ->
it
'stores the created highlight spans in _highlights'
,
->
hl
=
createTestHighlight
()
assert
.
equal
hl
.
_highlights
,
"test highlight span"
it
"wraps a jQuery element around the highlight span"
,
->
hl
=
createTestHighlight
()
assert
.
equal
jqElement
.
selector
,
"test highlight span"
assert
.
equal
hl
.
_highlights
.
textContent
,
"test highlight span"
it
"assigns the annotation as data to the highlight span"
,
->
hl
=
createTestHighlight
()
assert
.
calledWith
jqElement
.
data
,
"annotation"
,
"test annotation"
annotation
=
$
(
hl
.
_highlights
).
data
"annotation"
assert
.
equal
annotation
,
"test annotation"
describe
"scrollIntoView"
,
->
it
'calls jQuery scrollintoview'
,
->
hl
=
createTestHighlight
()
hl
.
scrollIntoView
()
assert
.
called
jqElement
.
scrollintoview
assert
.
called
Annotator
.
$
.
fn
.
scrollintoview
it
'scrolls to the created highlight span'
,
->
hl
=
createTestHighlight
()
...
...
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