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
8376c570
Commit
8376c570
authored
Dec 03, 2015
by
Sean Hammond
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for editing annotations on initialization
parent
1ae2f1ed
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
0 deletions
+73
-0
annotation-test.js
h/static/scripts/directive/test/annotation-test.js
+73
-0
No files found.
h/static/scripts/directive/test/annotation-test.js
View file @
8376c570
...
...
@@ -566,6 +566,79 @@ describe('annotation.js', function() {
assert
.
notCalled
(
annotation
.
$create
);
});
it
(
'edits new annotations on initialization'
,
function
()
{
// When the user creates a new annotation and we create a new
// AnnotationController instance, we automatically open the
// annotation's editor.
// A new annotation will have no id or $highlight.
annotation
.
id
=
annotation
.
$highlight
=
undefined
;
// A new annotation won't have any text or tags yet.
annotation
.
text
=
''
;
annotation
.
tags
=
[];
// A new annotation won't have any saved drafts yet.
fakeDrafts
.
get
.
returns
(
null
);
var
controller
=
createDirective
().
controller
;
assert
.
isTrue
(
controller
.
editing
());
});
it
(
'edits annotations with drafts on initialization'
,
function
()
{
// This is not a new annotation.
annotation
.
id
=
'annotation_id'
;
// This is not a highlight.
annotation
.
$highlight
=
undefined
;
annotation
.
text
=
'Annotation text'
;
annotation
.
tags
=
[
'tag_1'
,
'tag_2'
];
// The drafts service has some draft changes for this annotation.
fakeDrafts
.
get
.
returns
(
'foo'
);
var
controller
=
createDirective
().
controller
;
assert
.
isTrue
(
controller
.
editing
());
});
it
(
'does not edit new highlights on initialization'
,
function
()
{
// This is a new annotation.
annotation
.
id
=
undefined
;
fakeDrafts
.
get
.
returns
(
null
);
// This is a highlight.
annotation
.
$highlight
=
true
;
annotation
.
text
=
''
;
annotation
.
tags
=
[];
// We have to set annotation.$create() because it'll try to call it.
annotation
.
$create
=
sandbox
.
stub
().
returns
({
then
:
function
()
{}
});
var
controller
=
createDirective
().
controller
;
assert
.
isFalse
(
controller
.
editing
());
});
it
(
'edits highlights with drafts on initialization'
,
function
()
{
// You can edit a highlight, enter some text or tags, and save it (the
// highlight then becomes an annotation). You can also edit a highlight
// and then change focus to another group and back without saving the
// highlight, in which case the highlight will have draft edits.
//
// This is not a new highlight.
annotation
.
id
=
'annotation_id'
;
annotation
.
$highlight
=
undefined
;
// This is a highlight.
annotation
.
text
=
''
;
annotation
.
tags
=
[];
// This highlight has draft edits.
fakeDrafts
.
get
.
returns
(
'foo'
);
var
controller
=
createDirective
().
controller
;
assert
.
isTrue
(
controller
.
editing
());
});
});
describe
(
'AnnotationController.editing()'
,
function
()
{
...
...
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