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
22daea99
Commit
22daea99
authored
Sep 10, 2020
by
Tom Quirk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test todo counter updates in design management
parent
c32c9d9f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
spec/frontend/design_management/components/design_todo_button_spec.js
...d/design_management/components/design_todo_button_spec.js
+30
-0
No files found.
spec/frontend/design_management/components/design_todo_button_spec.js
View file @
22daea99
...
@@ -4,6 +4,7 @@ import DesignTodoButton from '~/design_management/components/design_todo_button.
...
@@ -4,6 +4,7 @@ import DesignTodoButton from '~/design_management/components/design_todo_button.
import
createDesignTodoMutation
from
'
~/design_management/graphql/mutations/create_design_todo.mutation.graphql
'
;
import
createDesignTodoMutation
from
'
~/design_management/graphql/mutations/create_design_todo.mutation.graphql
'
;
import
todoMarkDoneMutation
from
'
~/graphql_shared/mutations/todo_mark_done.mutation.graphql
'
;
import
todoMarkDoneMutation
from
'
~/graphql_shared/mutations/todo_mark_done.mutation.graphql
'
;
import
mockDesign
from
'
../mock_data/design
'
;
import
mockDesign
from
'
../mock_data/design
'
;
import
*
as
utils
from
'
~/design_management/utils/design_management_utils
'
;
const
mockDesignWithPendingTodos
=
{
const
mockDesignWithPendingTodos
=
{
...
mockDesign
,
...
mockDesign
,
...
@@ -52,6 +53,7 @@ describe('Design management design todo button', () => {
...
@@ -52,6 +53,7 @@ describe('Design management design todo button', () => {
afterEach
(()
=>
{
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
wrapper
=
null
;
jest
.
clearAllMocks
();
});
});
it
(
'
renders TodoButton component
'
,
()
=>
{
it
(
'
renders TodoButton component
'
,
()
=>
{
...
@@ -69,6 +71,11 @@ describe('Design management design todo button', () => {
...
@@ -69,6 +71,11 @@ describe('Design management design todo button', () => {
describe
(
'
when clicked
'
,
()
=>
{
describe
(
'
when clicked
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
utils
.
dispatchDocumentEvent
=
jest
.
fn
();
jest
.
spyOn
(
document
,
'
querySelector
'
).
mockReturnValue
({
innerText
:
2
,
});
createComponent
({
design
:
mockDesignWithPendingTodos
},
{
mountFn
:
mount
});
createComponent
({
design
:
mockDesignWithPendingTodos
},
{
mountFn
:
mount
});
wrapper
.
trigger
(
'
click
'
);
wrapper
.
trigger
(
'
click
'
);
return
wrapper
.
vm
.
$nextTick
();
return
wrapper
.
vm
.
$nextTick
();
...
@@ -86,6 +93,15 @@ describe('Design management design todo button', () => {
...
@@ -86,6 +93,15 @@ describe('Design management design todo button', () => {
expect
(
mutate
).
toHaveBeenCalledTimes
(
1
);
expect
(
mutate
).
toHaveBeenCalledTimes
(
1
);
expect
(
mutate
).
toHaveBeenCalledWith
(
todoMarkDoneMutationVariables
);
expect
(
mutate
).
toHaveBeenCalledWith
(
todoMarkDoneMutationVariables
);
});
});
it
(
'
calls dispatchDocumentEvent to update global To-Do counter correctly
'
,
()
=>
{
expect
(
utils
.
dispatchDocumentEvent
).
toHaveBeenCalledTimes
(
1
);
expect
(
utils
.
dispatchDocumentEvent
).
toHaveBeenCalledWith
(
'
todo:toggle
'
,
{
detail
:
{
count
:
1
,
},
});
});
});
});
});
});
...
@@ -100,6 +116,11 @@ describe('Design management design todo button', () => {
...
@@ -100,6 +116,11 @@ describe('Design management design todo button', () => {
describe
(
'
when clicked
'
,
()
=>
{
describe
(
'
when clicked
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
utils
.
dispatchDocumentEvent
=
jest
.
fn
();
jest
.
spyOn
(
document
,
'
querySelector
'
).
mockReturnValue
({
innerText
:
2
,
});
createComponent
({},
{
mountFn
:
mount
});
createComponent
({},
{
mountFn
:
mount
});
wrapper
.
trigger
(
'
click
'
);
wrapper
.
trigger
(
'
click
'
);
return
wrapper
.
vm
.
$nextTick
();
return
wrapper
.
vm
.
$nextTick
();
...
@@ -121,6 +142,15 @@ describe('Design management design todo button', () => {
...
@@ -121,6 +142,15 @@ describe('Design management design todo button', () => {
expect
(
mutate
).
toHaveBeenCalledTimes
(
1
);
expect
(
mutate
).
toHaveBeenCalledTimes
(
1
);
expect
(
mutate
).
toHaveBeenCalledWith
(
createDesignTodoMutationVariables
);
expect
(
mutate
).
toHaveBeenCalledWith
(
createDesignTodoMutationVariables
);
});
});
it
(
'
calls dispatchDocumentEvent to update global To-Do counter correctly
'
,
()
=>
{
expect
(
utils
.
dispatchDocumentEvent
).
toHaveBeenCalledTimes
(
1
);
expect
(
utils
.
dispatchDocumentEvent
).
toHaveBeenCalledWith
(
'
todo:toggle
'
,
{
detail
:
{
count
:
3
,
},
});
});
});
});
});
});
});
});
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