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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
88380a04
Commit
88380a04
authored
Apr 26, 2017
by
Phil Hughes
Committed by
Douwe Maan
Apr 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added specs for JS method to switch views
parent
95658fb6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
2 deletions
+39
-2
spec/javascripts/blob/viewer/index_spec.js
spec/javascripts/blob/viewer/index_spec.js
+39
-2
No files found.
spec/javascripts/blob/viewer/index_spec.js
View file @
88380a04
/* eslint-disable no-new */
import
BlobViewer
from
'
~/blob/viewer/index
'
;
fdescribe
(
'
Blob viewer
'
,
()
=>
{
describe
(
'
Blob viewer
'
,
()
=>
{
let
blob
;
preloadFixtures
(
'
blob/show.html.raw
'
);
beforeEach
(()
=>
{
loadFixtures
(
'
blob/show.html.raw
'
);
$
(
'
#modal-upload-blob
'
).
remove
();
new
BlobViewer
();
blob
=
new
BlobViewer
();
spyOn
(
$
,
'
ajax
'
).
and
.
callFake
(()
=>
{
const
d
=
$
.
Deferred
();
...
...
@@ -121,4 +122,40 @@ fdescribe('Blob viewer', () => {
});
});
});
describe
(
'
switchToViewer
'
,
()
=>
{
it
(
'
removes active class from old viewer button
'
,
()
=>
{
blob
.
switchToViewer
(
'
simple
'
);
expect
(
document
.
querySelector
(
'
.js-blob-viewer-switch-btn.active[data-viewer="rich"]
'
),
).
toBeNull
();
});
it
(
'
adds active class to new viewer button
'
,
()
=>
{
const
simpleBtn
=
document
.
querySelector
(
'
.js-blob-viewer-switch-btn[data-viewer="simple"]
'
);
spyOn
(
simpleBtn
,
'
blur
'
);
blob
.
switchToViewer
(
'
simple
'
);
expect
(
simpleBtn
.
classList
.
contains
(
'
active
'
),
).
toBeTruthy
();
expect
(
simpleBtn
.
blur
).
toHaveBeenCalled
();
});
it
(
'
sends AJAX request when switching to simple view
'
,
()
=>
{
blob
.
switchToViewer
(
'
simple
'
);
expect
(
$
.
ajax
).
toHaveBeenCalled
();
});
it
(
'
does not send AJAX request when switching to rich view
'
,
()
=>
{
blob
.
switchToViewer
(
'
simple
'
);
blob
.
switchToViewer
(
'
rich
'
);
expect
(
$
.
ajax
.
calls
.
count
()).
toBe
(
1
);
});
});
});
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