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
56de2455
Commit
56de2455
authored
Feb 13, 2015
by
csillag
Committed by
Gergely Ujvari
Feb 22, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding tests for applyUpdate
parent
5b488a77
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
0 deletions
+66
-0
controllers-test.coffee
tests/js/controllers-test.coffee
+66
-0
No files found.
tests/js/controllers-test.coffee
View file @
56de2455
...
@@ -3,6 +3,7 @@ sinon.assert.expose assert, prefix: null
...
@@ -3,6 +3,7 @@ sinon.assert.expose assert, prefix: null
describe
'h'
,
->
describe
'h'
,
->
$scope
=
null
$scope
=
null
fakeAnnotationMapper
=
null
fakeIdentity
=
null
fakeIdentity
=
null
fakeLocation
=
null
fakeLocation
=
null
fakeParams
=
null
fakeParams
=
null
...
@@ -10,6 +11,7 @@ describe 'h', ->
...
@@ -10,6 +11,7 @@ describe 'h', ->
fakeStore
=
fakeStore
=
SearchResource
:
SearchResource
:
get
:
sinon
.
spy
()
get
:
sinon
.
spy
()
fakeThreading
=
null
sandbox
=
null
sandbox
=
null
...
@@ -35,10 +37,18 @@ describe 'h', ->
...
@@ -35,10 +37,18 @@ describe 'h', ->
send
:
sandbox
.
spy
()
send
:
sandbox
.
spy
()
}
}
fakeAnnotationMapper
=
loadAnnotations
:
sandbox
.
spy
()
fakeThreading
=
idTable
:
{}
$provide
.
value
'identity'
,
fakeIdentity
$provide
.
value
'identity'
,
fakeIdentity
$provide
.
value
'streamer'
,
fakeStreamer
$provide
.
value
'streamer'
,
fakeStreamer
$provide
.
value
'$location'
,
fakeLocation
$provide
.
value
'$location'
,
fakeLocation
$provide
.
value
'$routeParams'
,
fakeParams
$provide
.
value
'$routeParams'
,
fakeParams
$provide
.
value
'annotationMapper'
,
fakeAnnotationMapper
$provide
.
value
'threading'
,
fakeThreading
return
return
afterEach
->
afterEach
->
...
@@ -49,6 +59,7 @@ describe 'h', ->
...
@@ -49,6 +59,7 @@ describe 'h', ->
beforeEach
inject
(
$controller
,
$rootScope
)
->
beforeEach
inject
(
$controller
,
$rootScope
)
->
$scope
=
$rootScope
.
$new
()
$scope
=
$rootScope
.
$new
()
$scope
.
$digest
=
sinon
.
spy
()
createController
=
->
createController
=
->
$controller
(
'AppController'
,
{
$scope
:
$scope
})
$controller
(
'AppController'
,
{
$scope
:
$scope
})
...
@@ -57,6 +68,61 @@ describe 'h', ->
...
@@ -57,6 +68,61 @@ describe 'h', ->
createController
()
createController
()
assert
.
isFalse
(
$scope
.
dialog
.
visible
)
assert
.
isFalse
(
$scope
.
dialog
.
visible
)
describe
'applyUpdate'
,
->
it
'calls annotationMapper.loadAnnotations() upon "create" action'
,
->
createController
()
anns
=
[
"my"
,
"annotations"
]
fakeStreamer
.
onmessage
type
:
"annotation-notification"
options
:
action
:
"create"
payload
:
anns
assert
.
calledWith
fakeAnnotationMapper
.
loadAnnotations
,
anns
it
'calls annotationMapper.loadAnnotations() upon "update" action'
,
->
createController
()
anns
=
[
"my"
,
"annotations"
]
fakeStreamer
.
onmessage
type
:
"annotation-notification"
options
:
action
:
"update"
payload
:
anns
assert
.
calledWith
fakeAnnotationMapper
.
loadAnnotations
,
anns
it
'calls annotationMapper.loadAnnotations() upon "past" action'
,
->
createController
()
anns
=
[
"my"
,
"annotations"
]
fakeStreamer
.
onmessage
type
:
"annotation-notification"
options
:
action
:
"past"
payload
:
anns
assert
.
calledWith
fakeAnnotationMapper
.
loadAnnotations
,
anns
it
'looks up annotations at threading upon "delete" action'
,
->
createController
()
$scope
.
$emit
=
sinon
.
spy
()
# Prepare the annotation that will come "from the wire"
anns
=
[
id
:
"fakeId"
data
:
"remote data"
]
# Prepare the annotation that we have locally
localAnnotation
=
id
:
"fake it"
data
:
"local data"
# Put our annotation into the threading id table
fakeThreading
.
idTable
.
fakeId
=
message
:
localAnnotation
# Simulate a delete action
fakeStreamer
.
onmessage
type
:
"annotation-notification"
options
:
action
:
"delete"
payload
:
anns
assert
.
calledWith
$scope
.
$emit
,
"annotationDeleted"
,
localAnnotation
describe
'AnnotationViewerController'
,
->
describe
'AnnotationViewerController'
,
->
annotationViewer
=
null
annotationViewer
=
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