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
dac3a45a
Commit
dac3a45a
authored
Aug 25, 2020
by
Tom Quirk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unnecessary props from todo_button
parent
bd99c8b6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
41 deletions
+14
-41
app/assets/javascripts/vue_shared/components/todo_button.vue
app/assets/javascripts/vue_shared/components/todo_button.vue
+4
-24
spec/frontend/vue_shared/components/todo_button_spec.js
spec/frontend/vue_shared/components/todo_button_spec.js
+10
-17
No files found.
app/assets/javascripts/vue_shared/components/todo_button.vue
View file @
dac3a45a
...
@@ -7,20 +7,12 @@ export default {
...
@@ -7,20 +7,12 @@ export default {
GlButton
,
GlButton
,
},
},
props
:
{
props
:
{
issuableId
:
{
type
:
Number
,
required
:
true
,
},
issuableType
:
{
type
:
String
,
required
:
true
,
},
isTodo
:
{
isTodo
:
{
type
:
Boolean
,
type
:
Boolean
,
required
:
false
,
required
:
false
,
default
:
true
,
default
:
true
,
},
},
isActionActive
:
{
loading
:
{
type
:
Boolean
,
type
:
Boolean
,
required
:
false
,
required
:
false
,
default
:
false
,
default
:
false
,
...
@@ -31,23 +23,11 @@ export default {
...
@@ -31,23 +23,11 @@ export default {
return
this
.
isTodo
?
__
(
'
Mark as done
'
)
:
__
(
'
Add a To-Do
'
);
return
this
.
isTodo
?
__
(
'
Mark as done
'
)
:
__
(
'
Add a To-Do
'
);
},
},
},
},
methods
:
{
toggleTodo
()
{
this
.
$emit
(
'
toggleTodo
'
,
{
issuableType
:
this
.
issuableType
,
issuableId
:
this
.
issuableId
,
});
},
},
};
};
</
script
>
</
script
>
<
template
>
<
template
>
<div>
<gl-button
:loading=
"loading"
:aria-label=
"buttonLabel"
@
click=
"$emit('click', $event)"
>
<slot
:toggleTodo=
"toggleTodo"
:label=
"buttonLabel"
>
<gl-button
:loading=
"isActionActive"
:aria-label=
"buttonLabel"
@
click=
"toggleTodo"
>
{{
buttonLabel
}}
{{
buttonLabel
}}
</gl-button></slot
</gl-button>
>
</div>
</
template
>
</
template
>
spec/frontend/vue_shared/components/todo_button_spec.js
View file @
dac3a45a
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
,
mount
}
from
'
@vue/test-utils
'
;
import
{
GlButton
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
GlButton
}
from
'
@gitlab/ui
'
;
import
TodoButton
from
'
~/vue_shared/components/todo_button.vue
'
;
import
TodoButton
from
'
~/vue_shared/components/todo_button.vue
'
;
const
defaultProps
=
{
issuableId
:
1
,
issuableType
:
'
epic
'
,
};
describe
(
'
Todo Button
'
,
()
=>
{
describe
(
'
Todo Button
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
const
createComponent
=
(
props
=
{})
=>
{
const
createComponent
=
(
props
=
{}
,
mountFn
=
shallowMount
)
=>
{
wrapper
=
mount
(
TodoButton
,
{
wrapper
=
mount
Fn
(
TodoButton
,
{
propsData
:
{
propsData
:
{
...
defaultProps
,
...
props
,
...
props
,
},
},
});
});
...
@@ -29,12 +23,11 @@ describe('Todo Button', () => {
...
@@ -29,12 +23,11 @@ describe('Todo Button', () => {
expect
(
wrapper
.
find
(
GlButton
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
GlButton
).
exists
()).
toBe
(
true
);
});
});
it
(
'
emits
toggleTodo
event when clicked
'
,
()
=>
{
it
(
'
emits
click
event when clicked
'
,
()
=>
{
createComponent
();
createComponent
(
{},
mount
);
wrapper
.
find
(
GlButton
).
trigger
(
'
click
'
);
wrapper
.
find
(
GlButton
).
trigger
(
'
click
'
);
expect
(
wrapper
.
emitted
().
toggleTodo
).
toBeTruthy
();
expect
(
wrapper
.
emitted
().
click
).
toBeTruthy
();
expect
(
wrapper
.
emitted
().
toggleTodo
[
0
]).
toEqual
([
defaultProps
]);
});
});
it
.
each
`
it
.
each
`
...
@@ -47,9 +40,9 @@ describe('Todo Button', () => {
...
@@ -47,9 +40,9 @@ describe('Todo Button', () => {
expect
(
wrapper
.
find
(
GlButton
).
text
()).
toBe
(
label
);
expect
(
wrapper
.
find
(
GlButton
).
text
()).
toBe
(
label
);
});
});
it
(
'
renders loading icon when `isActionActive
` is true
'
,
()
=>
{
it
(
'
sets button props correctly when `loading
` is true
'
,
()
=>
{
createComponent
({
isActionActive
:
true
});
createComponent
({
loading
:
true
});
expect
(
wrapper
.
find
(
Gl
LoadingIcon
).
exists
(
)).
toBe
(
true
);
expect
(
wrapper
.
find
(
Gl
Button
).
props
(
'
loading
'
)).
toBe
(
true
);
});
});
});
});
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