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
Hide 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'
;
const
angular
=
require
(
'angular'
);
const
proxyquire
=
require
(
'proxyquire'
);
const
fixtures
=
require
(
'../../test/annotation-fixtures'
);
const
annotationHeader
=
require
(
'../annotation-header'
);
const
fakeDocumentMeta
=
{
domain
:
'docs.io'
,
...
...
@@ -27,7 +27,7 @@ describe('sidebar.components.annotation-header', function() {
});
beforeEach
(
'Import and register the annotationHeader component'
,
function
()
{
const
annotationHeader
=
proxyquire
(
'../annotation-header'
,
{
annotationHeader
.
$imports
.
$mock
(
{
'../annotation-metadata'
:
{
// eslint-disable-next-line no-unused-vars
domainAndTitle
:
function
(
ann
)
{
...
...
@@ -35,12 +35,14 @@ describe('sidebar.components.annotation-header', function() {
},
},
'../util/account-id'
:
fakeAccountID
,
'@noCallThru'
:
true
,
});
angular
.
module
(
'app'
,
[]).
component
(
'annotationHeader'
,
annotationHeader
);
});
afterEach
(()
=>
{
annotationHeader
.
$imports
.
$restore
();
});
beforeEach
(
'Initialize and register fake AngularJS dependencies'
,
function
()
{
fakeFeatures
=
{
flagEnabled
:
sinon
.
stub
().
returns
(
false
),
...
...
src/sidebar/components/test/annotation-test.js
View file @
c4c5b043
'use strict'
;
const
angular
=
require
(
'angular'
);
const
proxyquire
=
require
(
'proxyquire'
);
const
events
=
require
(
'../../events'
);
const
fixtures
=
require
(
'../../test/annotation-fixtures'
);
const
testUtil
=
require
(
'../../../shared/test/util'
);
const
util
=
require
(
'../../directive/test/util'
);
const
annotationComponent
=
require
(
'../annotation'
);
const
inject
=
angular
.
mock
.
inject
;
const
unroll
=
testUtil
.
unroll
;
...
...
@@ -100,9 +101,6 @@ describe('annotation', function() {
let
$scope
;
let
$timeout
;
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
=
{
isThirdPartyUser
:
sinon
.
stub
(),
};
...
...
@@ -120,16 +118,15 @@ describe('annotation', function() {
let
fakeStreamer
;
let
sandbox
;
/**
* Returns the annotation directive with helpers stubbed out.
*/
function
annotationComponent
()
{
return
proxyquire
(
'../annotation'
,
{
angular
:
testUtil
.
noCallThru
(
angular
),
beforeEach
(()
=>
{
annotationComponent
.
$imports
.
$mock
({
'../util/account-id'
:
fakeAccountID
,
'@noCallThru'
:
true
,
});
}
});
afterEach
(()
=>
{
annotationComponent
.
$imports
.
$restore
();
});
function
createDirective
(
annotation
)
{
annotation
=
annotation
||
fixtures
.
defaultAnnotation
();
...
...
@@ -153,7 +150,7 @@ describe('annotation', function() {
before
(
function
()
{
angular
.
module
(
'h'
,
[])
.
component
(
'annotation'
,
annotationComponent
()
)
.
component
(
'annotation'
,
annotationComponent
)
.
component
(
'annotationActionButton'
,
{
bindings
:
{
icon
:
'<'
,
...
...
src/sidebar/components/test/sidebar-content-test.js
View file @
c4c5b043
'use strict'
;
const
angular
=
require
(
'angular'
);
const
proxyquire
=
require
(
'proxyquire'
);
const
EventEmitter
=
require
(
'tiny-emitter'
);
const
events
=
require
(
'../../events'
);
const
noCallThru
=
require
(
'../../../shared/test/util'
).
noCallThru
;
const
sidebarContent
=
require
(
'../sidebar-content'
)
;
const
uiConstants
=
require
(
'../../ui-constants'
);
let
searchClients
;
...
...
@@ -64,21 +63,12 @@ describe('sidebar.components.sidebar-content', function() {
angular
.
module
(
'h'
,
[])
.
service
(
'store'
,
require
(
'../../store'
))
.
component
(
'sidebarContent'
,
proxyquire
(
'../sidebar-content'
,
noCallThru
({
angular
:
angular
,
'../search-client'
:
FakeSearchClient
,
})
)
);
.
component
(
'sidebarContent'
,
sidebarContent
);
});
beforeEach
(
angular
.
mock
.
module
(
'h'
));
beforeEach
(
beforeEach
(
()
=>
{
angular
.
mock
.
module
(
function
(
$provide
)
{
searchClients
=
[];
sandbox
=
sinon
.
sandbox
.
create
();
...
...
@@ -142,8 +132,16 @@ describe('sidebar.components.sidebar-content', function() {
$provide
.
value
(
'streamFilter'
,
fakeStreamFilter
);
$provide
.
value
(
'groups'
,
fakeGroups
);
$provide
.
value
(
'settings'
,
fakeSettings
);
})
);
});
sidebarContent
.
$imports
.
$mock
({
'../search-client'
:
FakeSearchClient
,
});
});
afterEach
(()
=>
{
sidebarContent
.
$imports
.
$restore
();
});
function
setFrames
(
frames
)
{
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