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
888b7bb1
Commit
888b7bb1
authored
Jan 22, 2015
by
Aron Carroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update the annotation directive tests
parent
5bfca64c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
29 deletions
+28
-29
annotation.coffee
h/static/scripts/directives/annotation.coffee
+2
-2
controllers-test.coffee
tests/js/controllers-test.coffee
+0
-2
annotation-test.coffee
tests/js/directives/annotation-test.coffee
+26
-25
No files found.
h/static/scripts/directives/annotation.coffee
View file @
888b7bb1
...
...
@@ -300,8 +300,8 @@ AnnotationController = [
# an embedded widget.
###
annotationDirective
=
[
'$document'
,
'annotationMapper'
,
(
$document
,
annotationMapper
)
->
'$document'
,
(
$document
)
->
linkFn
=
(
scope
,
elem
,
attrs
,
[
ctrl
,
thread
,
threadFilter
,
counter
])
->
# Observe the embedded attribute
attrs
.
$observe
'annotationEmbedded'
,
(
value
)
->
...
...
tests/js/controllers-test.coffee
View file @
888b7bb1
...
...
@@ -48,7 +48,6 @@ describe 'h', ->
send
:
sandbox
.
spy
()
}
$provide
.
value
'annotator'
,
fakeAnnotator
$provide
.
value
'identity'
,
fakeIdentity
$provide
.
value
'streamer'
,
fakeStreamer
$provide
.
value
'$location'
,
fakeLocation
...
...
@@ -69,7 +68,6 @@ describe 'h', ->
it
'does not show login form for logged in users'
,
->
createController
()
$scope
.
$digest
()
assert
.
isFalse
(
$scope
.
dialog
.
visible
)
describe
'AnnotationViewerController'
,
->
...
...
tests/js/directives/annotation-test.coffee
View file @
888b7bb1
...
...
@@ -6,13 +6,14 @@ describe 'h.directives.annotation', ->
$document
=
null
$scope
=
null
$timeout
=
null
annotator
=
null
annotation
=
null
createController
=
null
flash
=
null
fakeAuth
=
null
fakeStore
=
null
fakeUser
=
null
fakeAnnotationMapper
=
null
fakeAnnotationUI
=
null
beforeEach
module
(
'h'
)
beforeEach
module
(
'h.templates'
)
...
...
@@ -20,9 +21,20 @@ describe 'h.directives.annotation', ->
beforeEach
module
(
$provide
)
->
fakeAuth
=
user
:
'acct:bill@localhost'
fakeAnnotationMapper
=
createAnnotation
:
sandbox
.
stub
().
returns
permissions
:
read
:
[
'acct:bill@localhost'
]
update
:
[
'acct:bill@localhost'
]
destroy
:
[
'acct:bill@localhost'
]
admin
:
[
'acct:bill@localhost'
]
deleteAnnotation
:
sandbox
.
stub
()
fakeAnnotationUI
=
{}
$provide
.
value
'auth'
,
fakeAuth
$provide
.
value
'store'
,
fakeStore
$provide
.
value
'annotationMapper'
,
fakeAnnotationMapper
$provide
.
value
'annotationUI'
,
fakeAnnotationUI
return
beforeEach
inject
(
_$compile_
,
$controller
,
_$document_
,
$rootScope
,
_$timeout_
)
->
...
...
@@ -31,11 +43,6 @@ describe 'h.directives.annotation', ->
$timeout
=
_$timeout_
$scope
=
$rootScope
.
$new
()
$scope
.
annotationGet
=
(
locals
)
->
annotation
annotator
=
{
createAnnotation
:
sandbox
.
spy
(
data
)
->
data
plugins
:
{},
publish
:
sandbox
.
spy
()
}
annotation
=
id
:
'deadbeef'
document
:
...
...
@@ -48,7 +55,6 @@ describe 'h.directives.annotation', ->
createController
=
->
$controller
'AnnotationController'
,
$scope
:
$scope
annotator
:
annotator
flash
:
flash
afterEach
->
...
...
@@ -56,7 +62,7 @@ describe 'h.directives.annotation', ->
describe
'when the annotation is a highlight'
,
->
beforeEach
->
annotator
.
tool
=
'highlight'
fakeAnnotationUI
.
tool
=
'highlight'
annotation
.
$create
=
sinon
.
stub
().
returns
then
:
angular
.
noop
catch
:
angular
.
noop
...
...
@@ -91,36 +97,31 @@ describe 'h.directives.annotation', ->
destroy
:
[
'acct:joe@localhost'
]
admin
:
[
'acct:joe@localhost'
]
annotator
.
publish
=
sinon
.
spy
(
event
,
ann
)
->
return
unless
event
==
'beforeAnnotationCreated'
ann
.
permissions
=
read
:
[
'acct:bill@localhost'
]
update
:
[
'acct:bill@localhost'
]
destroy
:
[
'acct:bill@localhost'
]
admin
:
[
'acct:bill@localhost'
]
it
'creates a new reply with the proper uri and references'
,
->
controller
.
reply
()
match
=
sinon
.
match
{
references
:
[
annotation
.
id
],
uri
:
annotation
.
uri
}
assert
.
calledWith
(
annotato
r
.
createAnnotation
,
match
)
assert
.
calledWith
(
fakeAnnotationMappe
r
.
createAnnotation
,
match
)
it
'adds the world readable principal if the parent is public'
,
->
reply
=
{}
fakeAnnotationMapper
.
createAnnotation
.
returns
(
reply
)
annotation
.
permissions
.
read
.
push
(
'group:__world__'
)
controller
.
reply
()
newAnnotation
=
annotator
.
createAnnotation
.
lastCall
.
args
[
0
]
assert
.
include
(
newAnnotation
.
permissions
.
read
,
'group:__world__'
)
assert
.
include
(
reply
.
permissions
.
read
,
'group:__world__'
)
it
'does not add the world readable principal if the parent is private'
,
->
reply
=
{}
fakeAnnotationMapper
.
createAnnotation
.
returns
(
reply
)
controller
.
reply
()
newAnnotation
=
annotator
.
createAnnotation
.
lastCall
.
args
[
0
]
assert
.
notInclude
(
newAnnotation
.
permissions
.
read
,
'group:__world__'
)
assert
.
notInclude
(
reply
.
permissions
.
read
,
'group:__world__'
)
it
'fills the other permissions too'
,
->
reply
=
{}
fakeAnnotationMapper
.
createAnnotation
.
returns
(
reply
)
controller
.
reply
()
newAnnotation
=
annotator
.
createAnnotation
.
lastCall
.
args
[
0
]
assert
.
equal
(
newAnnotation
.
permissions
.
update
[
0
],
'acct:bill@localhost'
)
assert
.
equal
(
newAnnotation
.
permissions
.
delete
[
0
],
'acct:bill@localhost'
)
assert
.
equal
(
newAnnotation
.
permissions
.
admin
[
0
],
'acct:bill@localhost'
)
assert
.
equal
(
reply
.
permissions
.
update
[
0
],
'acct:bill@localhost'
)
assert
.
equal
(
reply
.
permissions
.
delete
[
0
],
'acct:bill@localhost'
)
assert
.
equal
(
reply
.
permissions
.
admin
[
0
],
'acct:bill@localhost'
)
describe
'#render'
,
->
controller
=
null
...
...
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