BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
40e2be25
Unverified
Commit
40e2be25
authored
Apr 10, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added unit tests
parent
75d3ed9a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
457 additions
and
3 deletions
+457
-3
balsamiq_viewer.js
app/assets/javascripts/blob/balsamiq/balsamiq_viewer.js
+3
-3
balsamiq_viewer_spec.js
spec/javascripts/blob/balsamiq/balsamiq_viewer_spec.js
+357
-0
spinner_spec.js
spec/javascripts/spinner_spec.js
+97
-0
No files found.
app/assets/javascripts/blob/balsamiq/balsamiq_viewer.js
View file @
40e2be25
/* global Flash */
import
Spinner
from
'../../spinner'
;
import
sqljs
from
'sql.js'
;
import
Spinner
from
'../../spinner'
;
class
BalsamiqViewer
{
constructor
(
viewer
)
{
...
...
@@ -32,7 +32,7 @@ class BalsamiqViewer {
this
.
initDatabase
(
loadEvent
.
target
.
response
);
const
previews
=
this
.
getPreviews
();
const
renderedPreviews
=
previews
.
map
(
preview
=>
this
.
renderPreview
(
preview
,
container
));
const
renderedPreviews
=
previews
.
map
(
preview
=>
this
.
renderPreview
(
preview
));
container
.
innerHTML
=
renderedPreviews
.
join
(
''
);
container
.
classList
.
add
(
'list-inline'
,
'previews'
);
...
...
@@ -68,7 +68,7 @@ class BalsamiqViewer {
const
name
=
JSON
.
parse
(
title
[
0
].
values
[
0
][
2
]).
name
;
const
image
=
preview
.
image
;
template
=
template
.
replace
(
/{{name}}/
,
name
).
replace
(
/{{image}}/
,
image
);
template
=
template
.
replace
(
/{{name}}/
g
,
name
).
replace
(
/{{image}}/g
,
image
);
return
template
;
}
...
...
spec/javascripts/blob/balsamiq/balsamiq_viewer_spec.js
0 → 100644
View file @
40e2be25
This diff is collapsed.
Click to expand it.
spec/javascripts/spinner_spec.js
0 → 100644
View file @
40e2be25
import
Spinner
from
'~/spinner'
;
import
ClassSpecHelper
from
'./helpers/class_spec_helper'
;
describe
(
'Spinner'
,
()
=>
{
let
renderable
;
let
container
;
let
spinner
;
describe
(
'class constructor'
,
()
=>
{
beforeEach
(()
=>
{
renderable
=
{};
container
=
{};
spyOn
(
Spinner
,
'createContainer'
).
and
.
returnValue
(
container
);
spinner
=
new
Spinner
(
renderable
);
});
it
(
'should set .renderable'
,
()
=>
{
expect
(
spinner
.
renderable
).
toBe
(
renderable
);
});
it
(
'should call Spinner.createContainer'
,
()
=>
{
expect
(
Spinner
.
createContainer
).
toHaveBeenCalled
();
});
it
(
'should set .container'
,
()
=>
{
expect
(
spinner
.
container
).
toBe
(
container
);
});
});
describe
(
'start'
,
()
=>
{
beforeEach
(()
=>
{
renderable
=
jasmine
.
createSpyObj
(
'renderable'
,
[
'prepend'
]);
container
=
{};
spinner
=
{
renderable
,
container
,
};
Spinner
.
prototype
.
start
.
call
(
spinner
);
});
it
(
'should call .prepend'
,
()
=>
{
expect
(
renderable
.
prepend
).
toHaveBeenCalledWith
(
container
);
});
});
describe
(
'stop'
,
()
=>
{
beforeEach
(()
=>
{
container
=
jasmine
.
createSpyObj
(
'container'
,
[
'remove'
]);
spinner
=
{
container
,
};
Spinner
.
prototype
.
stop
.
call
(
spinner
);
});
it
(
'should call .remove'
,
()
=>
{
expect
(
container
.
remove
).
toHaveBeenCalled
();
});
});
describe
(
'createContainer'
,
()
=>
{
let
createContainer
;
beforeEach
(()
=>
{
container
=
{
classList
:
jasmine
.
createSpyObj
(
'classList'
,
[
'add'
]),
};
spyOn
(
document
,
'createElement'
).
and
.
returnValue
(
container
);
createContainer
=
Spinner
.
createContainer
();
});
ClassSpecHelper
.
itShouldBeAStaticMethod
(
Spinner
,
'createContainer'
);
it
(
'should call document.createElement'
,
()
=>
{
expect
(
document
.
createElement
).
toHaveBeenCalledWith
(
'div'
);
});
it
(
'should call classList.add'
,
()
=>
{
expect
(
container
.
classList
.
add
).
toHaveBeenCalledWith
(
'loading'
);
});
it
(
'should return the container element'
,
()
=>
{
expect
(
createContainer
).
toBe
(
container
);
});
it
(
'should set the container .innerHTML to Spinner.TEMPLATE'
,
()
=>
{
expect
(
container
.
innerHTML
).
toBe
(
Spinner
.
TEMPLATE
);
});
});
});
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