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
e0670e4c
Commit
e0670e4c
authored
Apr 11, 2019
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert mocking from proxyquire to mockable-imports
Convert proxyquire mocking of several CoffeeScript modules.
parent
6a9248a8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
15 deletions
+17
-15
cross-frame-test.coffee
src/annotator/plugin/test/cross-frame-test.coffee
+3
-5
host-test.coffee
src/annotator/test/host-test.coffee
+1
-2
multi-frame-test.js
src/annotator/test/integration/multi-frame-test.js
+4
-2
sidebar-test.coffee
src/annotator/test/sidebar-test.coffee
+9
-6
No files found.
src/annotator/plugin/test/cross-frame-test.coffee
View file @
e0670e4c
proxyquire
=
require
(
'proxyquire'
)
Plugin
=
require
(
'../../plugin'
)
Plugin
=
require
(
'../../plugin'
)
CrossFrame
=
null
CrossFrame
=
require
(
'../cross-frame'
)
describe
'CrossFrame'
,
->
describe
'CrossFrame'
,
->
fakeDiscovery
=
null
fakeDiscovery
=
null
...
@@ -41,16 +39,16 @@ describe 'CrossFrame', ->
...
@@ -41,16 +39,16 @@ describe 'CrossFrame', ->
proxyDiscovery
=
sandbox
.
stub
().
returns
(
fakeDiscovery
)
proxyDiscovery
=
sandbox
.
stub
().
returns
(
fakeDiscovery
)
proxyBridge
=
sandbox
.
stub
().
returns
(
fakeBridge
)
proxyBridge
=
sandbox
.
stub
().
returns
(
fakeBridge
)
CrossFrame
=
proxyquire
(
'../cross-frame'
,
{
CrossFrame
.
$imports
.
$mock
(
{
'../plugin'
:
Plugin
,
'../plugin'
:
Plugin
,
'../annotation-sync'
:
proxyAnnotationSync
,
'../annotation-sync'
:
proxyAnnotationSync
,
'../../shared/bridge'
:
proxyBridge
,
'../../shared/bridge'
:
proxyBridge
,
'../../shared/discovery'
:
proxyDiscovery
'../../shared/discovery'
:
proxyDiscovery
})
})
afterEach
->
afterEach
->
sandbox
.
restore
()
sandbox
.
restore
()
CrossFrame
.
$imports
.
$restore
()
describe
'CrossFrame constructor'
,
->
describe
'CrossFrame constructor'
,
->
it
'instantiates the Discovery component'
,
->
it
'instantiates the Discovery component'
,
->
...
...
src/annotator/test/host-test.coffee
View file @
e0670e4c
proxyquire
=
require
(
'proxyquire'
)
Host
=
require
(
'../host'
)
Host
=
proxyquire
(
'../host'
,
{})
describe
'Host'
,
->
describe
'Host'
,
->
sandbox
=
sinon
.
sandbox
.
create
()
sandbox
=
sinon
.
sandbox
.
create
()
...
...
src/annotator/test/integration/multi-frame-test.js
View file @
e0670e4c
'use strict'
;
'use strict'
;
const
proxyquire
=
require
(
'proxyquire'
);
const
isLoaded
=
require
(
'../../util/frame-util'
).
isLoaded
;
const
isLoaded
=
require
(
'../../util/frame-util'
).
isLoaded
;
const
FRAME_DEBOUNCE_WAIT
=
require
(
'../../frame-observer'
).
DEBOUNCE_WAIT
+
10
;
const
FRAME_DEBOUNCE_WAIT
=
require
(
'../../frame-observer'
).
DEBOUNCE_WAIT
+
10
;
const
CrossFrame
=
require
(
'../../plugin/cross-frame'
);
describe
(
'CrossFrame multi-frame scenario'
,
function
()
{
describe
(
'CrossFrame multi-frame scenario'
,
function
()
{
let
fakeAnnotationSync
;
let
fakeAnnotationSync
;
...
@@ -30,7 +30,7 @@ describe('CrossFrame multi-frame scenario', function() {
...
@@ -30,7 +30,7 @@ describe('CrossFrame multi-frame scenario', function() {
proxyAnnotationSync
=
sandbox
.
stub
().
returns
(
fakeAnnotationSync
);
proxyAnnotationSync
=
sandbox
.
stub
().
returns
(
fakeAnnotationSync
);
proxyBridge
=
sandbox
.
stub
().
returns
(
fakeBridge
);
proxyBridge
=
sandbox
.
stub
().
returns
(
fakeBridge
);
const
CrossFrame
=
proxyquire
(
'../../plugin/cross-frame'
,
{
CrossFrame
.
$imports
.
$mock
(
{
'../annotation-sync'
:
proxyAnnotationSync
,
'../annotation-sync'
:
proxyAnnotationSync
,
'../../shared/bridge'
:
proxyBridge
,
'../../shared/bridge'
:
proxyBridge
,
});
});
...
@@ -53,6 +53,8 @@ describe('CrossFrame multi-frame scenario', function() {
...
@@ -53,6 +53,8 @@ describe('CrossFrame multi-frame scenario', function() {
sandbox
.
restore
();
sandbox
.
restore
();
crossFrame
.
destroy
();
crossFrame
.
destroy
();
container
.
parentNode
.
removeChild
(
container
);
container
.
parentNode
.
removeChild
(
container
);
CrossFrame
.
$imports
.
$restore
();
});
});
it
(
'detects frames on page'
,
function
()
{
it
(
'detects frames on page'
,
function
()
{
...
...
src/annotator/test/sidebar-test.coffee
View file @
e0670e4c
events
=
require
(
'../../shared/bridge-events'
)
events
=
require
(
'../../shared/bridge-events'
)
proxyquire
=
require
(
'proxyquire'
)
Sidebar
=
require
(
'../sidebar'
)
rafStub
=
(
fn
)
->
fn
()
Sidebar
=
proxyquire
(
'../sidebar'
,
{
raf
:
rafStub
})
DEFAULT_WIDTH
=
350
DEFAULT_WIDTH
=
350
DEFAULT_HEIGHT
=
600
DEFAULT_HEIGHT
=
600
...
@@ -17,6 +12,14 @@ describe 'Sidebar', ->
...
@@ -17,6 +12,14 @@ describe 'Sidebar', ->
fakeCrossFrame
=
null
fakeCrossFrame
=
null
sidebarConfig
=
{
pluginClasses
:
{}}
sidebarConfig
=
{
pluginClasses
:
{}}
before
->
rafStub
=
(
fn
)
->
fn
()
Sidebar
.
$imports
.
$mock
({
raf
:
rafStub
})
after
->
Sidebar
.
$imports
.
$restore
()
createSidebar
=
(
config
=
{})
->
createSidebar
=
(
config
=
{})
->
config
=
Object
.
assign
({},
sidebarConfig
,
config
)
config
=
Object
.
assign
({},
sidebarConfig
,
config
)
element
=
document
.
createElement
(
'div'
)
element
=
document
.
createElement
(
'div'
)
...
...
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