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
7532310b
Commit
7532310b
authored
Apr 05, 2018
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GeoNode SectionRevealButton Component
parent
74e1e4a1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
111 additions
and
0 deletions
+111
-0
ee/app/assets/javascripts/geo_nodes/components/node_detail_sections/section_reveal_button.vue
...components/node_detail_sections/section_reveal_button.vue
+45
-0
spec/javascripts/geo_nodes/components/node_detail_sections/section_reveal_button_spec.js
...onents/node_detail_sections/section_reveal_button_spec.js
+66
-0
No files found.
ee/app/assets/javascripts/geo_nodes/components/node_detail_sections/section_reveal_button.vue
0 → 100644
View file @
7532310b
<
script
>
import
icon
from
'
~/vue_shared/components/icon.vue
'
;
export
default
{
components
:
{
icon
,
},
props
:
{
buttonTitle
:
{
type
:
String
,
required
:
true
,
},
},
data
()
{
return
{
toggleState
:
false
,
};
},
computed
:
{
toggleButtonIcon
()
{
return
this
.
toggleState
?
'
angle-up
'
:
'
angle-down
'
;
},
},
methods
:
{
onClickButton
()
{
this
.
toggleState
=
!
this
.
toggleState
;
this
.
$emit
(
'
toggleButton
'
,
this
.
toggleState
);
},
},
};
</
script
>
<
template
>
<button
class=
"btn-link btn-show-section"
type=
"button"
@
click=
"onClickButton"
>
<icon
:size=
"16"
:name=
"toggleButtonIcon"
/>
<span
class=
"prepend-left-8"
>
{{
buttonTitle
}}
</span>
</button>
</
template
>
spec/javascripts/geo_nodes/components/node_detail_sections/section_reveal_button_spec.js
0 → 100644
View file @
7532310b
import
Vue
from
'
vue
'
;
import
SectionRevealButtonComponent
from
'
ee/geo_nodes/components/node_detail_sections/section_reveal_button.vue
'
;
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
const
createComponent
=
(
buttonTitle
=
'
Foo button
'
)
=>
{
const
Component
=
Vue
.
extend
(
SectionRevealButtonComponent
);
return
mountComponent
(
Component
,
{
buttonTitle
,
});
};
describe
(
'
SectionRevealButton
'
,
()
=>
{
let
vm
;
beforeEach
(()
=>
{
vm
=
createComponent
();
});
afterEach
(()
=>
{
vm
.
$destroy
();
});
describe
(
'
data
'
,
()
=>
{
it
(
'
returns default data props
'
,
()
=>
{
expect
(
vm
.
toggleState
).
toBe
(
false
);
});
});
describe
(
'
computed
'
,
()
=>
{
it
(
'
return `angle-up` when toggleState prop is true
'
,
()
=>
{
vm
.
toggleState
=
true
;
expect
(
vm
.
toggleButtonIcon
).
toBe
(
'
angle-up
'
);
});
it
(
'
return `angle-down` when toggleState prop is false
'
,
()
=>
{
vm
.
toggleState
=
false
;
expect
(
vm
.
toggleButtonIcon
).
toBe
(
'
angle-down
'
);
});
});
describe
(
'
methods
'
,
()
=>
{
describe
(
'
onClickButton
'
,
()
=>
{
it
(
'
updates `toggleState` prop to toggle from previous value
'
,
()
=>
{
vm
.
toggleState
=
true
;
vm
.
onClickButton
();
expect
(
vm
.
toggleState
).
toBe
(
false
);
});
it
(
'
emits `toggleButton` event on component
'
,
()
=>
{
spyOn
(
vm
,
'
$emit
'
);
vm
.
onClickButton
();
expect
(
vm
.
$emit
).
toHaveBeenCalledWith
(
'
toggleButton
'
,
vm
.
toggleState
);
});
});
});
describe
(
'
template
'
,
()
=>
{
it
(
'
renders button element
'
,
()
=>
{
expect
(
vm
.
$el
.
classList
.
contains
(
'
btn-show-section
'
)).
toBe
(
true
);
expect
(
vm
.
$el
.
querySelector
(
'
svg use
'
).
getAttribute
(
'
xlink:href
'
)).
toContain
(
'
#angle-down
'
);
expect
(
vm
.
$el
.
querySelector
(
'
span
'
).
innerText
.
trim
()).
toBe
(
'
Foo button
'
);
});
});
});
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