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
ce2509ba
Commit
ce2509ba
authored
Mar 24, 2017
by
Robert Knight
Committed by
GitHub
Mar 24, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #310 from hypothesis/reorganise-annotation-sync-tests
Reorganize annotation sync tests
parents
6a8af948
877fb348
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
17 deletions
+17
-17
annotation-sync-test.js
src/annotator/test/annotation-sync-test.js
+17
-17
No files found.
src/annotator/test/annotation-sync-test.js
View file @
ce2509ba
...
@@ -45,9 +45,9 @@ describe('AnnotationSync', function() {
...
@@ -45,9 +45,9 @@ describe('AnnotationSync', function() {
sandbox
.
restore
();
sandbox
.
restore
();
});
});
describe
(
'
channel event handlers
'
,
function
()
{
describe
(
'
#constructor
'
,
function
()
{
describe
(
'the "deleteAnnotation" event
'
,
function
()
{
context
(
'when "deleteAnnotation" is published
'
,
function
()
{
it
(
'
broadcasts the "annotationDeleted" event over the local event bus
'
,
function
()
{
it
(
'
calls emit("annotationDeleted")
'
,
function
()
{
var
ann
=
{
id
:
1
,
$tag
:
'tag1'
};
var
ann
=
{
id
:
1
,
$tag
:
'tag1'
};
var
eventStub
=
sinon
.
stub
();
var
eventStub
=
sinon
.
stub
();
options
.
on
(
'annotationDeleted'
,
eventStub
);
options
.
on
(
'annotationDeleted'
,
eventStub
);
...
@@ -58,7 +58,7 @@ describe('AnnotationSync', function() {
...
@@ -58,7 +58,7 @@ describe('AnnotationSync', function() {
assert
.
calledWith
(
eventStub
,
ann
);
assert
.
calledWith
(
eventStub
,
ann
);
});
});
it
(
'calls back with a formatted annotation'
,
function
(
done
)
{
it
(
"calls the 'deleteAnnotation' event's callback function"
,
function
(
done
)
{
var
ann
=
{
id
:
1
,
$tag
:
'tag1'
};
var
ann
=
{
id
:
1
,
$tag
:
'tag1'
};
var
callback
=
function
(
err
,
ret
)
{
var
callback
=
function
(
err
,
ret
)
{
assert
.
isNull
(
err
);
assert
.
isNull
(
err
);
...
@@ -70,7 +70,7 @@ describe('AnnotationSync', function() {
...
@@ -70,7 +70,7 @@ describe('AnnotationSync', function() {
publish
(
'deleteAnnotation'
,
{
msg
:
ann
},
callback
);
publish
(
'deleteAnnotation'
,
{
msg
:
ann
},
callback
);
});
});
it
(
'
removes an existing entry from the cache before the event is triggered
'
,
function
()
{
it
(
'
deletes any existing annotation from its cache before calling emit
'
,
function
()
{
var
ann
=
{
id
:
1
,
$tag
:
'tag1'
};
var
ann
=
{
id
:
1
,
$tag
:
'tag1'
};
var
annSync
=
createAnnotationSync
();
var
annSync
=
createAnnotationSync
();
annSync
.
cache
.
tag1
=
ann
;
annSync
.
cache
.
tag1
=
ann
;
...
@@ -79,7 +79,7 @@ describe('AnnotationSync', function() {
...
@@ -79,7 +79,7 @@ describe('AnnotationSync', function() {
publish
(
'deleteAnnotation'
,
{
msg
:
ann
},
function
()
{});
publish
(
'deleteAnnotation'
,
{
msg
:
ann
},
function
()
{});
});
});
it
(
'
removes the annotation from the
cache'
,
function
()
{
it
(
'
deletes any existing annotation from its
cache'
,
function
()
{
var
ann
=
{
id
:
1
,
$tag
:
'tag1'
};
var
ann
=
{
id
:
1
,
$tag
:
'tag1'
};
var
annSync
=
createAnnotationSync
();
var
annSync
=
createAnnotationSync
();
annSync
.
cache
.
tag1
=
ann
;
annSync
.
cache
.
tag1
=
ann
;
...
@@ -90,8 +90,8 @@ describe('AnnotationSync', function() {
...
@@ -90,8 +90,8 @@ describe('AnnotationSync', function() {
});
});
});
});
describe
(
'the "loadAnnotations" event
'
,
function
()
{
context
(
'when "loadAnnotations" is published
'
,
function
()
{
it
(
'
publishes the "annotationsLoaded" event
'
,
function
()
{
it
(
'
calls emit("annotationsLoaded")
'
,
function
()
{
var
annotations
=
[
var
annotations
=
[
{
id
:
1
,
$tag
:
'tag1'
},
{
id
:
1
,
$tag
:
'tag1'
},
{
id
:
2
,
$tag
:
'tag2'
},
{
id
:
2
,
$tag
:
'tag2'
},
...
@@ -111,11 +111,9 @@ describe('AnnotationSync', function() {
...
@@ -111,11 +111,9 @@ describe('AnnotationSync', function() {
assert
.
calledWith
(
loadedStub
,
annotations
);
assert
.
calledWith
(
loadedStub
,
annotations
);
});
});
});
});
});
describe
(
'event handlers'
,
function
()
{
context
(
'when "beforeAnnotationCreated" is emitted'
,
function
()
{
describe
(
'the "beforeAnnotationCreated" event'
,
function
()
{
it
(
'calls bridge.call() passing the event'
,
function
()
{
it
(
'proxies the event over the bridge'
,
function
()
{
var
ann
=
{
id
:
1
};
var
ann
=
{
id
:
1
};
createAnnotationSync
();
createAnnotationSync
();
...
@@ -127,13 +125,15 @@ describe('AnnotationSync', function() {
...
@@ -127,13 +125,15 @@ describe('AnnotationSync', function() {
sinon
.
match
.
func
);
sinon
.
match
.
func
);
});
});
it
(
'returns early if the annotation has a tag'
,
function
()
{
context
(
'if the annotation has a $tag'
,
function
()
{
var
ann
=
{
id
:
1
,
$tag
:
'tag1'
};
it
(
'does not call bridge.call()'
,
function
()
{
createAnnotationSync
();
var
ann
=
{
id
:
1
,
$tag
:
'tag1'
};
createAnnotationSync
();
options
.
emit
(
'beforeAnnotationCreated'
,
ann
);
options
.
emit
(
'beforeAnnotationCreated'
,
ann
);
assert
.
notCalled
(
fakeBridge
.
call
);
assert
.
notCalled
(
fakeBridge
.
call
);
});
});
});
});
});
});
});
...
...
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