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
e0243919
Commit
e0243919
authored
Jan 27, 2015
by
Aron Carroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More CrossFrameService tests
parent
98366f3d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
1 deletion
+54
-1
cross-frame-service-test.coffee
tests/js/cross-frame-service-test.coffee
+54
-1
No files found.
tests/js/cross-frame-service-test.coffee
View file @
e0243919
...
@@ -3,11 +3,16 @@ sinon.assert.expose assert, prefix: null
...
@@ -3,11 +3,16 @@ sinon.assert.expose assert, prefix: null
describe
'CrossFrameService'
,
->
describe
'CrossFrameService'
,
->
sandbox
=
sinon
.
sandbox
.
create
()
sandbox
=
sinon
.
sandbox
.
create
()
crossframe
=
null
$rootScope
=
null
$rootScope
=
null
$fakeDocument
=
null
$fakeDocument
=
null
$fakeWindow
=
null
$fakeWindow
=
null
fakeStore
=
null
fakeStore
=
null
fakeAnnotationUI
=
null
fakeAnnotationUI
=
null
fakeCrossFrameDiscovery
=
null
fakeCrossFrameBridge
=
null
fakeAnnotationSync
=
null
fakeAnnotationUISync
=
null
beforeEach
module
(
'h'
)
beforeEach
module
(
'h'
)
beforeEach
module
(
$provide
)
->
beforeEach
module
(
$provide
)
->
...
@@ -15,11 +20,28 @@ describe 'CrossFrameService', ->
...
@@ -15,11 +20,28 @@ describe 'CrossFrameService', ->
$fakeWindow
=
{}
$fakeWindow
=
{}
fakeStore
=
{}
fakeStore
=
{}
fakeAnnotationUI
=
{}
fakeAnnotationUI
=
{}
fakeCrossFrameDiscovery
=
startDiscovery
:
sandbox
.
stub
()
fakeCrossFrameBridge
=
notify
:
sandbox
.
stub
()
createChannel
:
sandbox
.
stub
()
onConnect
:
sandbox
.
stub
()
fakeAnnotationSync
=
{}
fakeAnnotationUISync
=
{}
$provide
.
value
(
'$document'
,
$fakeDocument
)
$provide
.
value
(
'$document'
,
$fakeDocument
)
$provide
.
value
(
'$window'
,
$fakeWindow
)
$provide
.
value
(
'$window'
,
$fakeWindow
)
$provide
.
value
(
'store'
,
fakeStore
)
$provide
.
value
(
'store'
,
fakeStore
)
$provide
.
value
(
'annotationUI'
,
fakeAnnotationUI
)
$provide
.
value
(
'annotationUI'
,
fakeAnnotationUI
)
$provide
.
value
(
'CrossFrameDiscovery'
,
sandbox
.
stub
().
returns
(
fakeCrossFrameDiscovery
))
$provide
.
value
(
'CrossFrameBridge'
,
sandbox
.
stub
().
returns
(
fakeCrossFrameBridge
))
$provide
.
value
(
'AnnotationSync'
,
sandbox
.
stub
().
returns
(
fakeAnnotationSync
))
$provide
.
value
(
'AnnotationUISync'
,
sandbox
.
stub
().
returns
(
fakeAnnotationUISync
))
return
# $provide returns a promise.
beforeEach
inject
(
_$rootScope_
,
_crossframe_
)
->
beforeEach
inject
(
_$rootScope_
,
_crossframe_
)
->
$rootScope
=
_$rootScope_
$rootScope
=
_$rootScope_
...
@@ -29,5 +51,36 @@ describe 'CrossFrameService', ->
...
@@ -29,5 +51,36 @@ describe 'CrossFrameService', ->
sandbox
.
restore
()
sandbox
.
restore
()
describe
'.connect()'
,
->
describe
'.connect()'
,
->
it
'creates a new channel when the discovery module finds a frame'
,
->
fakeCrossFrameDiscovery
.
startDiscovery
.
yields
(
'source'
,
'origin'
,
'token'
)
crossframe
.
connect
()
assert
.
calledWith
(
fakeCrossFrameBridge
.
createChannel
,
'source'
,
'origin'
,
'token'
)
it
'queries discovered frames for metadata'
,
->
info
=
{
metadata
:
link
:
[{
href
:
'http://example.com'
}]}
channel
=
{
call
:
sandbox
.
stub
().
yieldsTo
(
'success'
,
info
)}
fakeCrossFrameBridge
.
onConnect
.
yields
(
channel
)
crossframe
.
connect
()
assert
.
calledWith
(
channel
.
call
,
{
method
:
'getDocumentInfo'
success
:
sinon
.
match
.
func
})
it
'updates the providers array'
,
->
info
=
{
metadata
:
link
:
[{
href
:
'http://example.com'
}]}
channel
=
{
call
:
sandbox
.
stub
().
yieldsTo
(
'success'
,
info
)}
fakeCrossFrameBridge
.
onConnect
.
yields
(
channel
)
crossframe
.
connect
()
assert
.
deepEqual
(
crossframe
.
providers
,
[
{
channel
:
channel
,
entities
:
[
'http://example.com'
]}
])
describe
'.notify()'
,
->
describe
'.notify()'
,
->
it
'proxies the call to the bridge'
it
'proxies the call to the bridge'
,
->
message
=
{
method
:
'foo'
,
params
:
'bar'
}
crossframe
.
connect
()
# create the bridge.
crossframe
.
notify
(
message
)
assert
.
calledOn
(
fakeCrossFrameBridge
.
notify
,
fakeCrossFrameBridge
)
assert
.
calledWith
(
fakeCrossFrameBridge
.
notify
,
message
)
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