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
2a618a03
Commit
2a618a03
authored
Jan 28, 2015
by
Aron Carroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for remaining channel handlers
parent
a68907ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
2 deletions
+28
-2
annotation-sync.coffee
h/static/scripts/annotation-sync.coffee
+2
-2
annotation-sync-test.coffee
tests/js/annotation-sync-test.coffee
+26
-0
No files found.
h/static/scripts/annotation-sync.coffee
View file @
2a618a03
...
@@ -87,10 +87,10 @@ class AnnotationSync
...
@@ -87,10 +87,10 @@ class AnnotationSync
res
res
'sync'
:
(
ctx
,
bodies
)
->
'sync'
:
(
ctx
,
bodies
)
->
this
.
_format
(
this
.
_parse
(
b
))
for
b
in
bodies
(
this
.
_format
(
this
.
_parse
(
b
))
for
b
in
bodies
)
'loadAnnotations'
:
(
txn
,
bodies
)
->
'loadAnnotations'
:
(
txn
,
bodies
)
->
annotations
=
(
this
.
_parse
(
a
)
for
a
in
annotation
s
)
annotations
=
(
this
.
_parse
(
a
)
for
a
in
bodie
s
)
@
_emit
(
'loadAnnotations'
,
annotations
)
@
_emit
(
'loadAnnotations'
,
annotations
)
# Handlers for events coming from this frame, to send them across the channel
# Handlers for events coming from this frame, to send them across the channel
...
...
tests/js/annotation-sync-test.coffee
View file @
2a618a03
...
@@ -144,3 +144,29 @@ describe 'AnnotationSync', ->
...
@@ -144,3 +144,29 @@ describe 'AnnotationSync', ->
assert
(
!
annSync
.
cache
[
'tag1'
])
assert
(
!
annSync
.
cache
[
'tag1'
])
describe
'on "sync" event'
,
->
it
'returns an array of parsed and formatted annotations'
,
->
options
.
parser
=
sinon
.
spy
((
x
)
->
x
)
options
.
formatter
=
sinon
.
spy
((
x
)
->
x
)
annSync
=
createAnnotationSync
()
annotations
=
[{
id
:
1
,
$
$tag
:
'tag1'
},
{
id
:
2
,
$
$tag
:
'tag2'
},
{
id
:
3
,
$
$tag
:
'tag3'
}]
bodies
=
({
msg
:
ann
,
tag
:
ann
.
$
$tag
}
for
ann
in
annotations
)
ret
=
publish
(
method
:
'sync'
,
params
:
bodies
)
assert
.
deepEqual
(
ret
,
ret
)
assert
.
called
(
options
.
parser
)
assert
.
called
(
options
.
formatter
)
describe
'on "loadAnnotations" event'
,
->
it
'publishes the "loadAnnotations" event with parsed annotations'
,
->
options
.
parser
=
sinon
.
spy
((
x
)
->
x
)
annSync
=
createAnnotationSync
()
annotations
=
[{
id
:
1
,
$
$tag
:
'tag1'
},
{
id
:
2
,
$
$tag
:
'tag2'
},
{
id
:
3
,
$
$tag
:
'tag3'
}]
bodies
=
({
msg
:
ann
,
tag
:
ann
.
$
$tag
}
for
ann
in
annotations
)
ret
=
publish
(
method
:
'loadAnnotations'
,
params
:
bodies
)
assert
.
called
(
options
.
parser
)
assert
.
calledWith
(
options
.
emit
,
'loadAnnotations'
,
annotations
)
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