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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
7a2f1073
Commit
7a2f1073
authored
Dec 22, 2017
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ItemStatsValue Component
parent
c2951f6f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
148 additions
and
0 deletions
+148
-0
app/assets/javascripts/groups/components/item_stats_value.vue
...assets/javascripts/groups/components/item_stats_value.vue
+67
-0
spec/javascripts/groups/components/item_stats_value_spec.js
spec/javascripts/groups/components/item_stats_value_spec.js
+81
-0
No files found.
app/assets/javascripts/groups/components/item_stats_value.vue
0 → 100644
View file @
7a2f1073
<
script
>
import
tooltip
from
'
~/vue_shared/directives/tooltip
'
;
import
icon
from
'
~/vue_shared/components/icon.vue
'
;
export
default
{
props
:
{
title
:
{
type
:
String
,
required
:
true
,
},
cssClass
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
iconName
:
{
type
:
String
,
required
:
true
,
},
tooltipPlacement
:
{
type
:
String
,
required
:
false
,
default
:
'
top
'
,
},
/**
* value could either be number or string
* as `memberCount` is always passed as string
* while `subgroupCount` & `projectCount`
* are always number
*/
value
:
{
type
:
[
Number
,
String
],
required
:
false
,
default
:
''
,
},
},
directives
:
{
tooltip
,
},
components
:
{
icon
,
},
computed
:
{
isValuePresent
()
{
return
this
.
value
!==
''
;
},
},
};
</
script
>
<
template
>
<span
v-tooltip
data-container=
"body"
:data-placement=
"tooltipPlacement"
:class=
"cssClass"
:title=
"title"
>
<icon
:name=
"iconName"
/>
<span
v-if=
"isValuePresent"
class=
"stat-value"
>
{{
value
}}
</span>
</span>
</
template
>
spec/javascripts/groups/components/item_stats_value_spec.js
0 → 100644
View file @
7a2f1073
import
Vue
from
'
vue
'
;
import
itemStatsValueComponent
from
'
~/groups/components/item_stats_value.vue
'
;
import
mountComponent
from
'
../../helpers/vue_mount_component_helper
'
;
const
createComponent
=
({
title
,
cssClass
,
iconName
,
tooltipPlacement
,
value
})
=>
{
const
Component
=
Vue
.
extend
(
itemStatsValueComponent
);
return
mountComponent
(
Component
,
{
title
,
cssClass
,
iconName
,
tooltipPlacement
,
value
,
});
};
describe
(
'
ItemStatsValueComponent
'
,
()
=>
{
describe
(
'
computed
'
,
()
=>
{
let
vm
;
const
itemConfig
=
{
title
:
'
Subgroups
'
,
cssClass
:
'
number-subgroups
'
,
iconName
:
'
folder
'
,
tooltipPlacement
:
'
left
'
,
};
describe
(
'
isValuePresent
'
,
()
=>
{
it
(
'
returns true if non-empty `value` is present
'
,
()
=>
{
vm
=
createComponent
(
Object
.
assign
({},
itemConfig
,
{
value
:
10
}));
expect
(
vm
.
isValuePresent
).
toBeTruthy
();
});
it
(
'
returns false if empty `value` is present
'
,
()
=>
{
vm
=
createComponent
(
itemConfig
);
expect
(
vm
.
isValuePresent
).
toBeFalsy
();
});
afterEach
(()
=>
{
vm
.
$destroy
();
});
});
});
describe
(
'
template
'
,
()
=>
{
let
vm
;
beforeEach
(()
=>
{
vm
=
createComponent
({
title
:
'
Subgroups
'
,
cssClass
:
'
number-subgroups
'
,
iconName
:
'
folder
'
,
tooltipPlacement
:
'
left
'
,
value
:
10
,
});
});
it
(
'
renders component element correctly
'
,
()
=>
{
expect
(
vm
.
$el
.
classList
.
contains
(
'
number-subgroups
'
)).
toBeTruthy
();
expect
(
vm
.
$el
.
querySelectorAll
(
'
svg
'
).
length
>
0
).
toBeTruthy
();
expect
(
vm
.
$el
.
querySelectorAll
(
'
.stat-value
'
).
length
>
0
).
toBeTruthy
();
});
it
(
'
renders element tooltip correctly
'
,
()
=>
{
expect
(
vm
.
$el
.
dataset
.
originalTitle
).
toBe
(
'
Subgroups
'
);
expect
(
vm
.
$el
.
dataset
.
placement
).
toBe
(
'
left
'
);
});
it
(
'
renders element icon correctly
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
svg use
'
).
getAttribute
(
'
xlink:href
'
)).
toContain
(
'
folder
'
);
});
it
(
'
renders value count correctly
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.stat-value
'
).
innerText
.
trim
()).
toContain
(
'
10
'
);
});
afterEach
(()
=>
{
vm
.
$destroy
();
});
});
});
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