Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
5e31389a
Commit
5e31389a
authored
Jun 04, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
e232cab7
2e32e393
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
14 deletions
+51
-14
spec/frontend/activities_spec.js
spec/frontend/activities_spec.js
+1
-2
spec/frontend/api_spec.js
spec/frontend/api_spec.js
+1
-1
spec/frontend/autosave_spec.js
spec/frontend/autosave_spec.js
+8
-11
spec/frontend/helpers/local_storage_helper.js
spec/frontend/helpers/local_storage_helper.js
+41
-0
No files found.
spec/
javascripts
/activities_spec.js
→
spec/
frontend
/activities_spec.js
View file @
5e31389a
/* eslint-disable no-unused-expressions, no-prototype-builtins, no-new, no-shadow */
/* eslint-disable no-unused-expressions, no-prototype-builtins, no-new, no-shadow */
import
$
from
'
jquery
'
;
import
$
from
'
jquery
'
;
import
'
vendor/jquery.endless-scroll
'
;
import
Activities
from
'
~/activities
'
;
import
Activities
from
'
~/activities
'
;
import
Pager
from
'
~/pager
'
;
import
Pager
from
'
~/pager
'
;
...
@@ -40,7 +39,7 @@ describe('Activities', () => {
...
@@ -40,7 +39,7 @@ describe('Activities', () => {
beforeEach
(()
=>
{
beforeEach
(()
=>
{
loadFixtures
(
fixtureTemplate
);
loadFixtures
(
fixtureTemplate
);
spyOn
(
Pager
,
'
init
'
).
and
.
stub
(
);
jest
.
spyOn
(
Pager
,
'
init
'
).
mockImplementation
(()
=>
{}
);
new
Activities
();
new
Activities
();
});
});
...
...
spec/
javascripts
/api_spec.js
→
spec/
frontend
/api_spec.js
View file @
5e31389a
...
@@ -459,7 +459,7 @@ describe('Api', () => {
...
@@ -459,7 +459,7 @@ describe('Api', () => {
dummyProjectPath
,
dummyProjectPath
,
)}
/repository/branches`
;
)}
/repository/branches`
;
spyOn
(
axios
,
'
post
'
).
and
.
callThrough
(
);
jest
.
spyOn
(
axios
,
'
post
'
);
mock
.
onPost
(
expectedUrl
).
replyOnce
(
200
,
{
mock
.
onPost
(
expectedUrl
).
replyOnce
(
200
,
{
name
:
branch
,
name
:
branch
,
...
...
spec/
javascripts
/autosave_spec.js
→
spec/
frontend
/autosave_spec.js
View file @
5e31389a
import
$
from
'
jquery
'
;
import
$
from
'
jquery
'
;
import
Autosave
from
'
~/autosave
'
;
import
Autosave
from
'
~/autosave
'
;
import
AccessorUtilities
from
'
~/lib/utils/accessor
'
;
import
AccessorUtilities
from
'
~/lib/utils/accessor
'
;
import
{
useLocalStorageSpy
}
from
'
helpers/local_storage_helper
'
;
describe
(
'
Autosave
'
,
()
=>
{
describe
(
'
Autosave
'
,
()
=>
{
useLocalStorageSpy
();
let
autosave
;
let
autosave
;
const
field
=
$
(
'
<textarea></textarea>
'
);
const
field
=
$
(
'
<textarea></textarea>
'
);
const
key
=
'
key
'
;
const
key
=
'
key
'
;
describe
(
'
class constructor
'
,
()
=>
{
describe
(
'
class constructor
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
spyOn
(
AccessorUtilities
,
'
isLocalStorageAccessSafe
'
).
and
.
r
eturnValue
(
true
);
jest
.
spyOn
(
AccessorUtilities
,
'
isLocalStorageAccessSafe
'
).
mockR
eturnValue
(
true
);
spyOn
(
Autosave
.
prototype
,
'
restore
'
);
jest
.
spyOn
(
Autosave
.
prototype
,
'
restore
'
).
mockImplementation
(()
=>
{}
);
});
});
it
(
'
should set .isLocalStorageAvailable
'
,
()
=>
{
it
(
'
should set .isLocalStorageAvailable
'
,
()
=>
{
...
@@ -27,8 +30,6 @@ describe('Autosave', () => {
...
@@ -27,8 +30,6 @@ describe('Autosave', () => {
field
,
field
,
key
,
key
,
};
};
spyOn
(
window
.
localStorage
,
'
getItem
'
);
});
});
describe
(
'
if .isLocalStorageAvailable is `false`
'
,
()
=>
{
describe
(
'
if .isLocalStorageAvailable is `false`
'
,
()
=>
{
...
@@ -55,7 +56,7 @@ describe('Autosave', () => {
...
@@ -55,7 +56,7 @@ describe('Autosave', () => {
});
});
it
(
'
triggers jquery event
'
,
()
=>
{
it
(
'
triggers jquery event
'
,
()
=>
{
spyOn
(
autosave
.
field
,
'
trigger
'
).
and
.
callThrough
(
);
jest
.
spyOn
(
autosave
.
field
,
'
trigger
'
).
mockImplementation
(()
=>
{}
);
Autosave
.
prototype
.
restore
.
call
(
autosave
);
Autosave
.
prototype
.
restore
.
call
(
autosave
);
...
@@ -77,7 +78,7 @@ describe('Autosave', () => {
...
@@ -77,7 +78,7 @@ describe('Autosave', () => {
});
});
it
(
'
does not trigger event
'
,
()
=>
{
it
(
'
does not trigger event
'
,
()
=>
{
spyOn
(
field
,
'
trigger
'
).
and
.
callThrough
(
);
jest
.
spyOn
(
field
,
'
trigger
'
);
expect
(
field
.
trigger
).
not
.
toHaveBeenCalled
();
expect
(
field
.
trigger
).
not
.
toHaveBeenCalled
();
});
});
...
@@ -86,11 +87,9 @@ describe('Autosave', () => {
...
@@ -86,11 +87,9 @@ describe('Autosave', () => {
describe
(
'
save
'
,
()
=>
{
describe
(
'
save
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
autosave
=
jasmine
.
createSpyObj
(
'
autosave
'
,
[
'
reset
'
])
;
autosave
=
{
reset
:
jest
.
fn
()
}
;
autosave
.
field
=
field
;
autosave
.
field
=
field
;
field
.
val
(
'
value
'
);
field
.
val
(
'
value
'
);
spyOn
(
window
.
localStorage
,
'
setItem
'
);
});
});
describe
(
'
if .isLocalStorageAvailable is `false`
'
,
()
=>
{
describe
(
'
if .isLocalStorageAvailable is `false`
'
,
()
=>
{
...
@@ -123,8 +122,6 @@ describe('Autosave', () => {
...
@@ -123,8 +122,6 @@ describe('Autosave', () => {
autosave
=
{
autosave
=
{
key
,
key
,
};
};
spyOn
(
window
.
localStorage
,
'
removeItem
'
);
});
});
describe
(
'
if .isLocalStorageAvailable is `false`
'
,
()
=>
{
describe
(
'
if .isLocalStorageAvailable is `false`
'
,
()
=>
{
...
...
spec/frontend/helpers/local_storage_helper.js
0 → 100644
View file @
5e31389a
/**
* Manage the instance of a custom `window.localStorage`
*
* This only encapsulates the setup / teardown logic so that it can easily be
* reused with different implementations (i.e. a spy or a [fake][1])
*
* [1]: https://stackoverflow.com/a/41434763/1708147
*
* @param {() => any} fn Function that returns the object to use for localStorage
*/
const
useLocalStorage
=
fn
=>
{
const
origLocalStorage
=
window
.
localStorage
;
let
currentLocalStorage
;
Object
.
defineProperty
(
window
,
'
localStorage
'
,
{
get
:
()
=>
currentLocalStorage
,
});
beforeEach
(()
=>
{
currentLocalStorage
=
fn
();
});
afterEach
(()
=>
{
currentLocalStorage
=
origLocalStorage
;
});
};
/**
* Create an object with the localStorage interface but `jest.fn()` implementations.
*/
export
const
createLocalStorageSpy
=
()
=>
({
clear
:
jest
.
fn
(),
getItem
:
jest
.
fn
(),
setItem
:
jest
.
fn
(),
removeItem
:
jest
.
fn
(),
});
/**
* Before each test, overwrite `window.localStorage` with a spy implementation.
*/
export
const
useLocalStorageSpy
=
()
=>
useLocalStorage
(
createLocalStorageSpy
);
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