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
c4c5b043
Commit
c4c5b043
authored
Apr 11, 2019
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert uses of proxyquire in src/sidebar/components to mockable-imports
parent
3cdeb195
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
32 deletions
+29
-32
annotation-header-test.js
src/sidebar/components/test/annotation-header-test.js
+6
-4
annotation-test.js
src/sidebar/components/test/annotation-test.js
+10
-13
sidebar-content-test.js
src/sidebar/components/test/sidebar-content-test.js
+13
-15
No files found.
src/sidebar/components/test/annotation-header-test.js
View file @
c4c5b043
'use strict'
;
'use strict'
;
const
angular
=
require
(
'angular'
);
const
angular
=
require
(
'angular'
);
const
proxyquire
=
require
(
'proxyquire'
);
const
fixtures
=
require
(
'../../test/annotation-fixtures'
);
const
fixtures
=
require
(
'../../test/annotation-fixtures'
);
const
annotationHeader
=
require
(
'../annotation-header'
);
const
fakeDocumentMeta
=
{
const
fakeDocumentMeta
=
{
domain
:
'docs.io'
,
domain
:
'docs.io'
,
...
@@ -27,7 +27,7 @@ describe('sidebar.components.annotation-header', function() {
...
@@ -27,7 +27,7 @@ describe('sidebar.components.annotation-header', function() {
});
});
beforeEach
(
'Import and register the annotationHeader component'
,
function
()
{
beforeEach
(
'Import and register the annotationHeader component'
,
function
()
{
const
annotationHeader
=
proxyquire
(
'../annotation-header'
,
{
annotationHeader
.
$imports
.
$mock
(
{
'../annotation-metadata'
:
{
'../annotation-metadata'
:
{
// eslint-disable-next-line no-unused-vars
// eslint-disable-next-line no-unused-vars
domainAndTitle
:
function
(
ann
)
{
domainAndTitle
:
function
(
ann
)
{
...
@@ -35,12 +35,14 @@ describe('sidebar.components.annotation-header', function() {
...
@@ -35,12 +35,14 @@ describe('sidebar.components.annotation-header', function() {
},
},
},
},
'../util/account-id'
:
fakeAccountID
,
'../util/account-id'
:
fakeAccountID
,
'@noCallThru'
:
true
,
});
});
angular
.
module
(
'app'
,
[]).
component
(
'annotationHeader'
,
annotationHeader
);
angular
.
module
(
'app'
,
[]).
component
(
'annotationHeader'
,
annotationHeader
);
});
});
afterEach
(()
=>
{
annotationHeader
.
$imports
.
$restore
();
});
beforeEach
(
'Initialize and register fake AngularJS dependencies'
,
function
()
{
beforeEach
(
'Initialize and register fake AngularJS dependencies'
,
function
()
{
fakeFeatures
=
{
fakeFeatures
=
{
flagEnabled
:
sinon
.
stub
().
returns
(
false
),
flagEnabled
:
sinon
.
stub
().
returns
(
false
),
...
...
src/sidebar/components/test/annotation-test.js
View file @
c4c5b043
'use strict'
;
'use strict'
;
const
angular
=
require
(
'angular'
);
const
angular
=
require
(
'angular'
);
const
proxyquire
=
require
(
'proxyquire'
);
const
events
=
require
(
'../../events'
);
const
events
=
require
(
'../../events'
);
const
fixtures
=
require
(
'../../test/annotation-fixtures'
);
const
fixtures
=
require
(
'../../test/annotation-fixtures'
);
const
testUtil
=
require
(
'../../../shared/test/util'
);
const
testUtil
=
require
(
'../../../shared/test/util'
);
const
util
=
require
(
'../../directive/test/util'
);
const
util
=
require
(
'../../directive/test/util'
);
const
annotationComponent
=
require
(
'../annotation'
);
const
inject
=
angular
.
mock
.
inject
;
const
inject
=
angular
.
mock
.
inject
;
const
unroll
=
testUtil
.
unroll
;
const
unroll
=
testUtil
.
unroll
;
...
@@ -100,9 +101,6 @@ describe('annotation', function() {
...
@@ -100,9 +101,6 @@ describe('annotation', function() {
let
$scope
;
let
$scope
;
let
$timeout
;
let
$timeout
;
let
$window
;
let
$window
;
// Unfortunately fakeAccountID needs to be initialised here because it
// gets passed into proxyquire() _before_ the beforeEach() that initializes
// the rest of the fakes runs.
const
fakeAccountID
=
{
const
fakeAccountID
=
{
isThirdPartyUser
:
sinon
.
stub
(),
isThirdPartyUser
:
sinon
.
stub
(),
};
};
...
@@ -120,16 +118,15 @@ describe('annotation', function() {
...
@@ -120,16 +118,15 @@ describe('annotation', function() {
let
fakeStreamer
;
let
fakeStreamer
;
let
sandbox
;
let
sandbox
;
/**
beforeEach
(()
=>
{
* Returns the annotation directive with helpers stubbed out.
annotationComponent
.
$imports
.
$mock
({
*/
function
annotationComponent
()
{
return
proxyquire
(
'../annotation'
,
{
angular
:
testUtil
.
noCallThru
(
angular
),
'../util/account-id'
:
fakeAccountID
,
'../util/account-id'
:
fakeAccountID
,
'@noCallThru'
:
true
,
});
});
}
});
afterEach
(()
=>
{
annotationComponent
.
$imports
.
$restore
();
});
function
createDirective
(
annotation
)
{
function
createDirective
(
annotation
)
{
annotation
=
annotation
||
fixtures
.
defaultAnnotation
();
annotation
=
annotation
||
fixtures
.
defaultAnnotation
();
...
@@ -153,7 +150,7 @@ describe('annotation', function() {
...
@@ -153,7 +150,7 @@ describe('annotation', function() {
before
(
function
()
{
before
(
function
()
{
angular
angular
.
module
(
'h'
,
[])
.
module
(
'h'
,
[])
.
component
(
'annotation'
,
annotationComponent
()
)
.
component
(
'annotation'
,
annotationComponent
)
.
component
(
'annotationActionButton'
,
{
.
component
(
'annotationActionButton'
,
{
bindings
:
{
bindings
:
{
icon
:
'<'
,
icon
:
'<'
,
...
...
src/sidebar/components/test/sidebar-content-test.js
View file @
c4c5b043
'use strict'
;
'use strict'
;
const
angular
=
require
(
'angular'
);
const
angular
=
require
(
'angular'
);
const
proxyquire
=
require
(
'proxyquire'
);
const
EventEmitter
=
require
(
'tiny-emitter'
);
const
EventEmitter
=
require
(
'tiny-emitter'
);
const
events
=
require
(
'../../events'
);
const
events
=
require
(
'../../events'
);
const
noCallThru
=
require
(
'../../../shared/test/util'
).
noCallThru
;
const
sidebarContent
=
require
(
'../sidebar-content'
)
;
const
uiConstants
=
require
(
'../../ui-constants'
);
const
uiConstants
=
require
(
'../../ui-constants'
);
let
searchClients
;
let
searchClients
;
...
@@ -64,21 +63,12 @@ describe('sidebar.components.sidebar-content', function() {
...
@@ -64,21 +63,12 @@ describe('sidebar.components.sidebar-content', function() {
angular
angular
.
module
(
'h'
,
[])
.
module
(
'h'
,
[])
.
service
(
'store'
,
require
(
'../../store'
))
.
service
(
'store'
,
require
(
'../../store'
))
.
component
(
.
component
(
'sidebarContent'
,
sidebarContent
);
'sidebarContent'
,
proxyquire
(
'../sidebar-content'
,
noCallThru
({
angular
:
angular
,
'../search-client'
:
FakeSearchClient
,
})
)
);
});
});
beforeEach
(
angular
.
mock
.
module
(
'h'
));
beforeEach
(
angular
.
mock
.
module
(
'h'
));
beforeEach
(
beforeEach
(
()
=>
{
angular
.
mock
.
module
(
function
(
$provide
)
{
angular
.
mock
.
module
(
function
(
$provide
)
{
searchClients
=
[];
searchClients
=
[];
sandbox
=
sinon
.
sandbox
.
create
();
sandbox
=
sinon
.
sandbox
.
create
();
...
@@ -142,8 +132,16 @@ describe('sidebar.components.sidebar-content', function() {
...
@@ -142,8 +132,16 @@ describe('sidebar.components.sidebar-content', function() {
$provide
.
value
(
'streamFilter'
,
fakeStreamFilter
);
$provide
.
value
(
'streamFilter'
,
fakeStreamFilter
);
$provide
.
value
(
'groups'
,
fakeGroups
);
$provide
.
value
(
'groups'
,
fakeGroups
);
$provide
.
value
(
'settings'
,
fakeSettings
);
$provide
.
value
(
'settings'
,
fakeSettings
);
})
});
);
sidebarContent
.
$imports
.
$mock
({
'../search-client'
:
FakeSearchClient
,
});
});
afterEach
(()
=>
{
sidebarContent
.
$imports
.
$restore
();
});
function
setFrames
(
frames
)
{
function
setFrames
(
frames
)
{
frames
.
forEach
(
function
(
frame
)
{
frames
.
forEach
(
function
(
frame
)
{
...
...
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