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
f8a3823e
Commit
f8a3823e
authored
Oct 29, 2015
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests to check use of drafts store and group focus changes in annotation directive
parent
72e37852
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
annotation-test.coffee
h/static/scripts/directive/test/annotation-test.coffee
+55
-0
No files found.
h/static/scripts/directive/test/annotation-test.coffee
View file @
f8a3823e
...
...
@@ -528,6 +528,61 @@ describe 'annotation', ->
assert
fakeFlash
.
error
.
notCalled
describe
"drafts"
,
->
it
"creates a draft when editing an annotation"
,
->
createDirective
()
controller
.
edit
()
assert
.
calledWith
(
fakeDrafts
.
update
,
annotation
,
{
text
:
annotation
.
text
,
tags
:
annotation
.
tags
,
})
it
"starts editing immediately if there is a draft"
,
->
fakeDrafts
.
get
.
returns
({
tags
:
[{
text
:
'unsaved'
}]
text
:
'unsaved-text'
})
createDirective
()
assert
.
isTrue
(
controller
.
editing
)
it
"uses the text and tags from the draft if present"
,
->
fakeDrafts
.
get
.
returns
({
tags
:
[
'unsaved-tag'
]
text
:
'unsaved-text'
})
createDirective
()
assert
.
deepEqual
(
controller
.
annotation
.
tags
,
[{
text
:
'unsaved-tag'
}])
assert
.
equal
(
controller
.
annotation
.
text
,
'unsaved-text'
)
it
"removes the draft when changes are discarded"
,
->
createDirective
()
controller
.
edit
()
controller
.
revert
()
assert
.
calledWith
(
fakeDrafts
.
remove
,
annotation
)
describe
"when the focused group changes"
,
->
it
"updates the current draft"
,
->
createDirective
()
controller
.
edit
()
controller
.
annotation
.
text
=
'unsaved-text'
controller
.
annotation
.
tags
=
[]
fakeDrafts
.
update
=
sinon
.
stub
()
$rootScope
.
$broadcast
(
events
.
GROUP_FOCUSED
)
assert
.
calledWith
(
fakeDrafts
.
update
,
annotation
,
{
text
:
'unsaved-text'
,
tags
:
[]
})
it
"moves new annotations to the focused group"
,
->
annotation
.
id
=
null
createDirective
()
fakeGroups
.
focused
=
sinon
.
stub
().
returns
({
id
:
'new-group'
})
$rootScope
.
$broadcast
(
events
.
GROUP_FOCUSED
)
assert
.
equal
(
annotation
.
group
,
'new-group'
)
describe
(
"AnnotationController"
,
->
before
(
->
...
...
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