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
1ae2f1ed
Commit
1ae2f1ed
authored
Dec 03, 2015
by
Sean Hammond
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for saving new highlights automatically
parent
0931f483
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
13 deletions
+98
-13
annotation-test.js
h/static/scripts/directive/test/annotation-test.js
+98
-13
No files found.
h/static/scripts/directive/test/annotation-test.js
View file @
1ae2f1ed
...
@@ -470,6 +470,104 @@ describe('annotation.js', function() {
...
@@ -470,6 +470,104 @@ describe('annotation.js', function() {
sandbox
.
restore
();
sandbox
.
restore
();
});
});
describe
(
'AnnotationController() initialization'
,
function
()
{
it
(
'saves new highlights to the server on initialization'
,
function
()
{
// New highlights have no id and have $highlight: true.
annotation
.
id
=
null
;
annotation
.
$highlight
=
true
;
// The user is logged-in.
annotation
.
user
=
fakeSession
.
state
.
userid
=
'acct:bill@localhost'
;
annotation
.
$create
=
sandbox
.
stub
().
returns
({
then
:
function
()
{}
});
createDirective
();
assert
.
called
(
annotation
.
$create
);
});
it
(
'saves new highlights to drafts if not logged in'
,
function
()
{
// New highlights have no id and have $highlight: true.
annotation
.
id
=
null
;
annotation
.
$highlight
=
true
;
// The user is not logged-in.
annotation
.
user
=
fakeSession
.
state
.
userid
=
undefined
;
annotation
.
$create
=
sandbox
.
stub
().
returns
({
then
:
function
()
{}
});
createDirective
();
assert
.
notCalled
(
annotation
.
$create
);
assert
.
called
(
fakeDrafts
.
update
);
});
it
(
'does not save new annotations on initialization'
,
function
()
{
// New annotations have no id and no $highlight.
annotation
.
id
=
null
;
annotation
.
$highlight
=
undefined
;
annotation
.
$create
=
sandbox
.
stub
().
returns
({
then
:
function
()
{}
});
createDirective
();
assert
.
notCalled
(
annotation
.
$create
);
});
it
(
'does not save old highlights on initialization'
,
function
()
{
// Old highlights (ones that the client has received from the server,
// rather than created locally itself) have an id and do not have any
// $highlight.
annotation
.
id
=
'annotation_id'
;
annotation
.
$highlight
=
undefined
;
// If it's a highlight, then the annotation will have a target but
// no references, text or tags.
annotation
.
target
=
[
'foo'
,
'bar'
];
annotation
.
references
=
[];
annotation
.
text
=
''
;
annotation
.
tags
=
[];
annotation
.
$create
=
sandbox
.
stub
().
returns
({
then
:
function
()
{}
});
createDirective
();
assert
.
notCalled
(
annotation
.
$create
);
});
it
(
'does not save old annotations on initialization'
,
function
()
{
// Old annotations (ones that the client has received from the server,
// rather than created locally itself) have an id and do not have any
// $highlight.
annotation
.
id
=
'annotation_id'
;
annotation
.
$highlight
=
undefined
;
// If it's an annotation (rather than a highlight, reply or page note)
// then the annotation will have a target, no references and some
// text or tags.
annotation
.
target
=
[
'foo'
,
'bar'
];
annotation
.
references
=
[];
annotation
.
text
=
'This is my annotation'
;
annotation
.
tags
=
[
'tag_1'
,
'tag_2'
];
annotation
.
$create
=
sandbox
.
stub
().
returns
({
then
:
function
()
{}
});
createDirective
();
assert
.
notCalled
(
annotation
.
$create
);
});
});
describe
(
'AnnotationController.editing()'
,
function
()
{
describe
(
'AnnotationController.editing()'
,
function
()
{
it
(
'returns true if action is "create"'
,
function
()
{
it
(
'returns true if action is "create"'
,
function
()
{
var
controller
=
createDirective
().
controller
;
var
controller
=
createDirective
().
controller
;
...
@@ -500,19 +598,6 @@ describe('annotation.js', function() {
...
@@ -500,19 +598,6 @@ describe('annotation.js', function() {
});
});
});
});
it
(
'persists upon login'
,
function
()
{
delete
annotation
.
id
;
delete
annotation
.
user
;
fakeSession
.
state
.
userid
=
null
;
createDirective
();
$scope
.
$digest
();
assert
.
notCalled
(
annotation
.
$create
);
fakeSession
.
state
.
userid
=
'acct:ted@wyldstallyns.com'
;
$scope
.
$broadcast
(
events
.
USER_CHANGED
,
{});
$scope
.
$digest
();
assert
.
calledOnce
(
annotation
.
$create
);
});
it
(
'is private'
,
function
()
{
it
(
'is private'
,
function
()
{
delete
annotation
.
id
;
delete
annotation
.
id
;
createDirective
();
createDirective
();
...
...
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