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
50233297
Commit
50233297
authored
Jul 25, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added binary_viewer editor and started on file_buttons spec
parent
032ae81d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
130 additions
and
39 deletions
+130
-39
spec/javascripts/repo/index_spec.js
spec/javascripts/repo/index_spec.js
+39
-39
spec/javascripts/repo/repo_binary_viewer_spec.js
spec/javascripts/repo/repo_binary_viewer_spec.js
+55
-0
spec/javascripts/repo/repo_editor_spec.js
spec/javascripts/repo/repo_editor_spec.js
+18
-0
spec/javascripts/repo/repo_file_buttons_spec.js
spec/javascripts/repo/repo_file_buttons_spec.js
+18
-0
No files found.
spec/javascripts/repo/index_spec.js
View file @
50233297
import
Tabs
from
'
~/repo/repo_tabs
'
;
import
Sidebar
from
'
~/repo/repo_sidebar
'
;
import
Editor
from
'
~/repo/repo_editor
'
;
import
FileButtons
from
'
~/repo/repo_file_buttons
'
;
import
EditButton
from
'
~/repo/repo_edit_button
'
;
import
BinaryViewer
from
'
~/repo/repo_binary_viewer
'
;
import
CommitSection
from
'
~/repo/repo_commit_section
'
;
import
Service
from
'
~/repo/repo_service
'
;
import
Store
from
'
~/repo/repo_store
'
;
import
Helper
from
'
~/repo/repo_helper
'
;
//
import Tabs from '~/repo/repo_tabs';
//
import Sidebar from '~/repo/repo_sidebar';
//
import Editor from '~/repo/repo_editor';
//
import FileButtons from '~/repo/repo_file_buttons';
//
import EditButton from '~/repo/repo_edit_button';
//
import BinaryViewer from '~/repo/repo_binary_viewer';
//
import CommitSection from '~/repo/repo_commit_section';
//
import Service from '~/repo/repo_service';
//
import Store from '~/repo/repo_store';
//
import Helper from '~/repo/repo_helper';
describe
(
'
initRepo
'
,
()
=>
{
const
url
=
'
url
'
;
//
describe('initRepo', () => {
//
const url = 'url';
it
(
'
should select all elements, set store service and url, init all needed classes and getContent
'
,
()
=>
{
spyOn
(
Helper
,
'
getContent
'
);
spyOn
(
document
,
'
getElementById
'
).
and
.
callFake
((
selector
)
=>
{
const
element
=
document
.
createElement
(
'
div
'
);
//
it('should select all elements, set store service and url, init all needed classes and getContent', () => {
//
spyOn(Helper, 'getContent');
//
spyOn(document, 'getElementById').and.callFake((selector) => {
//
const element = document.createElement('div');
if
(
selector
===
'
ide
'
)
element
.
dataset
.
url
=
url
;
//
if (selector === 'ide') element.dataset.url = url;
return
element
;
});
//
return element;
//
});
require
(
'
~/repo/index
'
);
// eslint-disable-line global-require
//
require('~/repo/index'); // eslint-disable-line global-require
expect
(
document
.
getElementById
).
toHaveBeenCalledWith
(
'
ide
'
);
expect
(
document
.
getElementById
).
toHaveBeenCalledWith
(
'
tabs
'
);
expect
(
document
.
getElementById
).
toHaveBeenCalledWith
(
'
sidebar
'
);
expect
(
document
.
getElementById
).
toHaveBeenCalledWith
(
'
repo-file-buttons
'
);
expect
(
document
.
getElementById
).
toHaveBeenCalledWith
(
'
editable-mode
'
);
expect
(
document
.
getElementById
).
toHaveBeenCalledWith
(
'
commit-area
'
);
expect
(
document
.
getElementById
).
toHaveBeenCalledWith
(
'
binary-viewer
'
);
expect
(
Store
.
service
).
toBe
(
Service
);
expect
(
Store
.
service
.
url
).
toBe
(
url
);
expect
(
Store
.
tabs
instanceof
Tabs
).
toBe
(
true
);
expect
(
Store
.
sidebar
instanceof
Sidebar
).
toBe
(
true
);
expect
(
Store
.
editor
instanceof
Editor
).
toBe
(
true
);
expect
(
Store
.
buttons
instanceof
FileButtons
).
toBe
(
true
);
expect
(
Store
.
editButton
instanceof
EditButton
).
toBe
(
true
);
expect
(
Store
.
commitSection
instanceof
CommitSection
).
toBe
(
true
);
expect
(
Store
.
binaryViewer
instanceof
BinaryViewer
).
toBe
(
true
);
expect
(
Helper
.
getContent
).
toHaveBeenCalled
();
});
});
//
expect(document.getElementById).toHaveBeenCalledWith('ide');
//
expect(document.getElementById).toHaveBeenCalledWith('tabs');
//
expect(document.getElementById).toHaveBeenCalledWith('sidebar');
//
expect(document.getElementById).toHaveBeenCalledWith('repo-file-buttons');
//
expect(document.getElementById).toHaveBeenCalledWith('editable-mode');
//
expect(document.getElementById).toHaveBeenCalledWith('commit-area');
//
expect(document.getElementById).toHaveBeenCalledWith('binary-viewer');
//
expect(Store.service).toBe(Service);
//
expect(Store.service.url).toBe(url);
//
expect(Store.tabs instanceof Tabs).toBe(true);
//
expect(Store.sidebar instanceof Sidebar).toBe(true);
//
expect(Store.editor instanceof Editor).toBe(true);
//
expect(Store.buttons instanceof FileButtons).toBe(true);
//
expect(Store.editButton instanceof EditButton).toBe(true);
//
expect(Store.commitSection instanceof CommitSection).toBe(true);
//
expect(Store.binaryViewer instanceof BinaryViewer).toBe(true);
//
expect(Helper.getContent).toHaveBeenCalled();
//
});
//
});
spec/javascripts/repo/repo_binary_viewer_spec.js
0 → 100644
View file @
50233297
import
Vue
from
'
vue
'
;
import
Store
from
'
~/repo/repo_store
'
;
import
repoBinaryViewer
from
'
~/repo/repo_binary_viewer.vue
'
;
describe
(
'
RepoBinaryViewer
'
,
()
=>
{
const
RepoBinaryViewer
=
Vue
.
extend
(
repoBinaryViewer
);
function
createComponent
()
{
return
new
RepoBinaryViewer
().
$mount
();
}
it
(
'
renders an img if its png
'
,
()
=>
{
const
binaryTypes
=
{
png
:
true
,
};
const
activeFile
=
{
name
:
'
name
'
,
};
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
'
);
expect
(
img
).
toBeTruthy
();
expect
(
img
.
src
).
toMatch
(
`/
${
uri
}
`
);
expect
(
img
.
alt
).
toEqual
(
activeFile
.
name
);
});
it
(
'
renders an div with content if its markdown
'
,
()
=>
{
const
binaryTypes
=
{
markdown
:
true
,
};
const
activeFile
=
{
html
:
'
markdown
'
,
};
Store
.
binary
=
true
;
Store
.
binaryTypes
=
binaryTypes
;
Store
.
activeFile
=
activeFile
;
const
vm
=
createComponent
();
const
markdown
=
vm
.
$el
.
querySelector
(
'
:scope > div
'
);
expect
(
markdown
).
toBeTruthy
();
expect
(
markdown
.
innerHTML
).
toEqual
(
activeFile
.
html
);
});
it
(
'
does not render if no binary
'
,
()
=>
{
Store
.
binary
=
false
;
const
vm
=
createComponent
();
expect
(
vm
.
$el
.
innerHTML
).
toBeFalsy
();
});
});
spec/javascripts/repo/repo_editor_spec.js
0 → 100644
View file @
50233297
import
Vue
from
'
vue
'
;
import
repoEditor
from
'
~/repo/repo_editor.vue
'
;
fdescribe
(
'
RepoEditor
'
,
()
=>
{
const
RepoEditor
=
Vue
.
extend
(
repoEditor
);
function
createComponent
()
{
return
new
RepoEditor
().
$mount
();
}
it
(
'
renders an ide container
'
,
()
=>
{
const
vm
=
createComponent
();
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
$el
.
getElementById
(
'
ide
'
)).
toBeTruthy
();
});
});
});
spec/javascripts/repo/repo_file_buttons_spec.js
0 → 100644
View file @
50233297
import
Vue
from
'
vue
'
;
import
repoFileButtons
from
'
~/repo/repo_file_buttons.vue
'
;
fdescribe
(
'
RepoFileButtons
'
,
()
=>
{
const
RepoFileButtons
=
Vue
.
extend
(
repoFileButtons
);
function
createComponent
()
{
return
new
RepoFileButtons
().
$mount
();
}
it
(
'
does not render if not isMini
'
,
()
=>
{
const
vm
=
createComponent
({});
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
$el
.
getElementById
(
'
ide
'
)).
toBeTruthy
();
});
});
});
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