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
395f899b
Commit
395f899b
authored
Mar 09, 2020
by
Nicolò Maria Mezzopera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate blob_file_dropzone to jest
parent
a03444a7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
spec/frontend/blob/blob_file_dropzone_spec.js
spec/frontend/blob/blob_file_dropzone_spec.js
+50
-0
No files found.
spec/
javascripts
/blob/blob_file_dropzone_spec.js
→
spec/
frontend
/blob/blob_file_dropzone_spec.js
View file @
395f899b
import
$
from
'
jquery
'
;
import
BlobFileDropzone
from
'
~/blob/blob_file_dropzone
'
;
describe
(
'
BlobFileDropzone
'
,
function
()
{
describe
(
'
BlobFileDropzone
'
,
()
=>
{
preloadFixtures
(
'
blob/show.html
'
);
let
dropzone
;
let
replaceFileButton
;
const
jQueryMock
=
{
enable
:
jest
.
fn
(),
disable
:
jest
.
fn
(),
};
beforeEach
(()
=>
{
loadFixtures
(
'
blob/show.html
'
);
const
form
=
$
(
'
.js-upload-blob-form
'
);
this
.
blobFileDropzone
=
new
BlobFileDropzone
(
form
,
'
POST
'
);
this
.
dropzone
=
$
(
'
.js-upload-blob-form .dropzone
'
).
get
(
0
).
dropzone
;
this
.
replaceFileButton
=
$
(
'
#submit-all
'
);
// eslint-disable-next-line no-new
new
BlobFileDropzone
(
form
,
'
POST
'
);
dropzone
=
$
(
'
.js-upload-blob-form .dropzone
'
).
get
(
0
).
dropzone
;
dropzone
.
processQueue
=
jest
.
fn
();
replaceFileButton
=
$
(
'
#submit-all
'
);
$
.
fn
.
extend
(
jQueryMock
);
});
describe
(
'
submit button
'
,
()
=>
{
it
(
'
requires file
'
,
()
=>
{
spyOn
(
window
,
'
alert
'
);
jest
.
spyOn
(
window
,
'
alert
'
).
mockImplementation
(()
=>
{}
);
this
.
replaceFileButton
.
click
();
replaceFileButton
.
click
();
expect
(
window
.
alert
).
toHaveBeenCalled
();
});
it
(
'
is disabled while uploading
'
,
()
=>
{
spyOn
(
window
,
'
alert
'
);
jest
.
spyOn
(
window
,
'
alert
'
).
mockImplementation
(()
=>
{}
);
const
file
=
new
File
([],
'
some-file.jpg
'
);
const
fakeEvent
=
$
.
Event
(
'
drop
'
,
{
dataTransfer
:
{
files
:
[
file
]
},
});
this
.
dropzone
.
listeners
[
0
].
events
.
drop
(
fakeEvent
);
this
.
replaceFileButton
.
click
();
dropzone
.
listeners
[
0
].
events
.
drop
(
fakeEvent
);
replaceFileButton
.
click
();
expect
(
window
.
alert
).
not
.
toHaveBeenCalled
();
expect
(
this
.
replaceFileButton
.
is
(
'
:disabled
'
)).
toEqual
(
true
);
expect
(
jQueryMock
.
enable
).
toHaveBeenCalled
();
expect
(
dropzone
.
processQueue
).
toHaveBeenCalled
();
});
});
});
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