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
4402eefa
Commit
4402eefa
authored
Aug 02, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ci skip] Improve repo_binary_viewer_spec
parent
e216a90b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
19 deletions
+56
-19
spec/javascripts/repo/repo_binary_viewer_spec.js
spec/javascripts/repo/repo_binary_viewer_spec.js
+55
-18
spec/javascripts/repo/repo_commit_section_spec.js
spec/javascripts/repo/repo_commit_section_spec.js
+1
-1
No files found.
spec/javascripts/repo/repo_binary_viewer_spec.js
View file @
4402eefa
...
...
@@ -9,40 +9,77 @@ describe('RepoBinaryViewer', () => {
return
new
RepoBinaryViewer
().
$mount
();
}
it
(
'
renders an img if its png
'
,
()
=>
{
const
binaryTypes
=
{
png
:
true
,
};
const
activeFile
=
{
name
:
'
name
'
,
};
function
createActiveFile
(
type
,
activeFile
=
{})
{
const
file
=
activeFile
;
switch
(
type
)
{
case
'
svg
'
:
case
'
png
'
:
file
.
name
=
'
name
'
;
break
;
case
'
md
'
:
file
.
html
=
'
html
'
;
break
;
default
:
break
;
}
return
file
;
}
function
setActiveBinary
(
type
)
{
const
binaryTypes
=
{};
binaryTypes
[
type
]
=
true
;
const
activeFile
=
createActiveFile
(
type
);
const
uri
=
'
uri
'
;
Store
.
binary
=
true
;
Store
.
binaryTypes
=
binaryTypes
;
Store
.
activeFile
=
activeFile
;
Store
.
pngBlobWithDataURI
=
uri
;
const
vm
=
createComponent
();
const
img
=
vm
.
$el
.
querySelector
(
'
:scope > img
'
);
return
{
activeFile
,
uri
,
};
}
function
assertBinaryImg
(
img
,
activeFile
,
uri
)
{
expect
(
img
.
src
).
toMatch
(
`/
${
uri
}
`
);
expect
(
img
.
alt
).
toEqual
(
activeFile
.
name
);
}
it
(
'
renders an img if its png
'
,
()
=>
{
const
{
activeFile
,
uri
}
=
setActiveBinary
(
'
png
'
);
const
vm
=
createComponent
();
const
img
=
vm
.
$el
.
querySelector
(
'
:scope > img
'
);
assertBinaryImg
(
img
,
activeFile
,
uri
);
});
it
(
'
renders an img if its svg
'
,
()
=>
{
const
{
activeFile
,
uri
}
=
setActiveBinary
(
'
svg
'
);
const
vm
=
createComponent
();
const
img
=
vm
.
$el
.
querySelector
(
'
:scope > img
'
);
assertBinaryImg
(
img
,
activeFile
,
uri
);
});
it
(
'
renders an div with content if its markdown
'
,
()
=>
{
const
binaryTypes
=
{
md
:
true
,
};
const
activeFile
=
{
html
:
'
markdown
'
,
};
Store
.
binary
=
true
;
Store
.
binaryTypes
=
binaryTypes
;
Store
.
activeFile
=
activeFile
;
const
{
activeFile
}
=
setActiveBinary
(
'
md
'
);
const
vm
=
createComponent
();
expect
(
vm
.
$el
.
querySelector
(
'
:scope > div
'
).
innerHTML
).
toEqual
(
activeFile
.
html
);
});
it
(
'
renders no preview message if its unknown
'
,
()
=>
{
setActiveBinary
(
'
unknown
'
);
const
vm
=
createComponent
();
expect
(
vm
.
$el
.
querySelector
(
'
.binary-unknown
'
).
textContent
).
toMatch
(
'
Binary file. No preview available.
'
);
});
it
(
'
does not render if no binary
'
,
()
=>
{
Store
.
binary
=
false
;
const
vm
=
createComponent
();
...
...
spec/javascripts/repo/repo_commit_section_spec.js
View file @
4402eefa
...
...
@@ -4,7 +4,7 @@ import RepoStore from '~/repo/repo_store';
import
RepoHelper
from
'
~/repo/repo_helper
'
;
import
Api
from
'
~/api
'
;
describe
(
'
RepoCommitSection
'
,
()
=>
{
f
describe
(
'
RepoCommitSection
'
,
()
=>
{
const
openedFiles
=
[{
id
:
0
,
changed
:
true
,
...
...
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