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
bd99c8b6
Commit
bd99c8b6
authored
Aug 20, 2020
by
Tom Quirk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for todo_button.vue
parent
74922897
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
8 deletions
+56
-8
app/assets/javascripts/vue_shared/components/todo_button.vue
app/assets/javascripts/vue_shared/components/todo_button.vue
+1
-8
spec/frontend/vue_shared/components/todo_button_spec.js
spec/frontend/vue_shared/components/todo_button_spec.js
+55
-0
No files found.
app/assets/javascripts/vue_shared/components/todo_button.vue
View file @
bd99c8b6
...
...
@@ -2,9 +2,6 @@
import
{
GlButton
}
from
'
@gitlab/ui
'
;
import
{
__
}
from
'
~/locale
'
;
const
MARK_TEXT
=
__
(
'
Mark as done
'
);
const
TODO_TEXT
=
__
(
'
Add a To-Do
'
);
export
default
{
components
:
{
GlButton
,
...
...
@@ -31,11 +28,7 @@ export default {
},
computed
:
{
buttonLabel
()
{
return
this
.
isTodo
?
MARK_TEXT
:
TODO_TEXT
;
},
buttonIcon
()
{
return
this
.
isTodo
?
'
todo-done
'
:
'
todo-add
'
;
return
this
.
isTodo
?
__
(
'
Mark as done
'
)
:
__
(
'
Add a To-Do
'
);
},
},
methods
:
{
...
...
spec/frontend/vue_shared/components/todo_button_spec.js
0 → 100644
View file @
bd99c8b6
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
GlButton
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
TodoButton
from
'
~/vue_shared/components/todo_button.vue
'
;
const
defaultProps
=
{
issuableId
:
1
,
issuableType
:
'
epic
'
,
};
describe
(
'
Todo Button
'
,
()
=>
{
let
wrapper
;
const
createComponent
=
(
props
=
{})
=>
{
wrapper
=
mount
(
TodoButton
,
{
propsData
:
{
...
defaultProps
,
...
props
,
},
});
};
afterEach
(()
=>
{
wrapper
.
destroy
();
});
it
(
'
renders GlButton
'
,
()
=>
{
createComponent
();
expect
(
wrapper
.
find
(
GlButton
).
exists
()).
toBe
(
true
);
});
it
(
'
emits toggleTodo event when clicked
'
,
()
=>
{
createComponent
();
wrapper
.
find
(
GlButton
).
trigger
(
'
click
'
);
expect
(
wrapper
.
emitted
().
toggleTodo
).
toBeTruthy
();
expect
(
wrapper
.
emitted
().
toggleTodo
[
0
]).
toEqual
([
defaultProps
]);
});
it
.
each
`
label | isTodo
${
'
Mark as done
'
}
|
${
true
}
${
'
Add a To-Do
'
}
|
${
false
}
`
(
'
sets correct label when isTodo is $isTodo
'
,
({
label
,
isTodo
})
=>
{
createComponent
({
isTodo
});
expect
(
wrapper
.
find
(
GlButton
).
text
()).
toBe
(
label
);
});
it
(
'
renders loading icon when `isActionActive` is true
'
,
()
=>
{
createComponent
({
isActionActive
:
true
});
expect
(
wrapper
.
find
(
GlLoadingIcon
).
exists
()).
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