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
4ce5878f
Commit
4ce5878f
authored
Jan 15, 2018
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
StackedProgressBar Component tests
parent
f632ae68
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
0 deletions
+77
-0
stacked_progress_bar_spec.js
...cripts/vue_shared/components/stacked_progress_bar_spec.js
+77
-0
No files found.
spec/javascripts/vue_shared/components/stacked_progress_bar_spec.js
0 → 100644
View file @
4ce5878f
import
Vue
from
'vue'
;
import
stackedProgressBarComponent
from
'~/vue_shared/components/stacked_progress_bar.vue'
;
import
mountComponent
from
'../../helpers/vue_mount_component_helper'
;
const
createComponent
=
(
config
)
=>
{
const
Component
=
Vue
.
extend
(
stackedProgressBarComponent
);
const
defaultConfig
=
Object
.
assign
({},
{
successLabel
:
'Synced'
,
failureLabel
:
'Failed'
,
neutralLabel
:
'Out of sync'
,
successCount
:
10
,
failureCount
:
5
,
totalCount
:
20
,
},
config
);
return
mountComponent
(
Component
,
defaultConfig
);
};
describe
(
'StackedProgressBarComponent'
,
()
=>
{
let
vm
;
beforeEach
(()
=>
{
vm
=
createComponent
();
});
afterEach
(()
=>
{
vm
.
$destroy
();
});
describe
(
'computed'
,
()
=>
{
describe
(
'neutralCount'
,
()
=>
{
it
(
'returns neutralCount based on totalCount, successCount and failureCount'
,
()
=>
{
expect
(
vm
.
neutralCount
).
toBe
(
5
);
// 20 - 10 - 5
});
});
});
describe
(
'methods'
,
()
=>
{
describe
(
'getPercent'
,
()
=>
{
it
(
'returns percentage from provided count based on `totalCount`'
,
()
=>
{
expect
(
vm
.
getPercent
(
10
)).
toBe
(
50
);
});
});
describe
(
'barStyle'
,
()
=>
{
it
(
'returns style string based on percentage provided'
,
()
=>
{
expect
(
vm
.
barStyle
(
50
)).
toBe
(
'width: 50%;'
);
});
});
describe
(
'getTooltip'
,
()
=>
{
it
(
'returns label string based on label and count provided'
,
()
=>
{
expect
(
vm
.
getTooltip
(
'Synced'
,
10
)).
toBe
(
'Synced: 10'
);
});
});
});
describe
(
'template'
,
()
=>
{
it
(
'renders container element'
,
()
=>
{
expect
(
vm
.
$el
.
classList
.
contains
(
'stacked-progress-bar'
)).
toBeTruthy
();
});
it
(
'renders empty state when count is unavailable'
,
()
=>
{
const
vmX
=
createComponent
({
totalCount
:
0
,
successCount
:
0
,
failureCount
:
0
});
expect
(
vmX
.
$el
.
querySelectorAll
(
'.status-unavailable'
).
length
).
not
.
toBe
(
0
);
vmX
.
$destroy
();
});
it
(
'renders bar elements when count is available'
,
()
=>
{
expect
(
vm
.
$el
.
querySelectorAll
(
'.status-green'
).
length
).
not
.
toBe
(
0
);
expect
(
vm
.
$el
.
querySelectorAll
(
'.status-neutral'
).
length
).
not
.
toBe
(
0
);
expect
(
vm
.
$el
.
querySelectorAll
(
'.status-red'
).
length
).
not
.
toBe
(
0
);
});
});
});
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