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
85fc8ab4
Commit
85fc8ab4
authored
Apr 19, 2021
by
Justin Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for Unlink button
Similar to spec in groups_list_item_spec.js Update translations
parent
868ccd00
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
4 deletions
+87
-4
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/frontend/jira_connect/components/subscriptions_list_spec.js
...ontend/jira_connect/components/subscriptions_list_spec.js
+84
-4
No files found.
locale/gitlab.pot
View file @
85fc8ab4
...
...
@@ -17149,6 +17149,9 @@ msgstr ""
msgid "Integrations|Failed to load namespaces. Please try again."
msgstr ""
msgid "Integrations|Failed to unlink namespace. Please try again."
msgstr ""
msgid "Integrations|Includes Standard plus entire commit message, commit hash, and issue IDs"
msgstr ""
...
...
spec/frontend/jira_connect/components/subscriptions_list_spec.js
View file @
85fc8ab4
import
{
GlEmptyState
,
GlTable
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
GlButton
,
GlEmptyState
,
GlTable
}
from
'
@gitlab/ui
'
;
import
{
mount
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
*
as
JiraConnectApi
from
'
~/jira_connect/api
'
;
import
SubscriptionsList
from
'
~/jira_connect/components/subscriptions_list.vue
'
;
import
createStore
from
'
~/jira_connect/store
'
;
import
{
SET_ALERT
}
from
'
~/jira_connect/store/mutation_types
'
;
import
{
reloadPage
}
from
'
~/jira_connect/utils
'
;
import
{
mockSubscription
}
from
'
../mock_data
'
;
jest
.
mock
(
'
~/jira_connect/utils
'
);
describe
(
'
SubscriptionsList
'
,
()
=>
{
let
wrapper
;
let
store
;
const
createComponent
=
({
mountFn
=
shallowMount
,
provide
=
{}
}
=
{})
=>
{
store
=
createStore
();
const
createComponent
=
({
provide
=
{}
}
=
{})
=>
{
wrapper
=
shallowMount
(
SubscriptionsList
,
{
wrapper
=
mountFn
(
SubscriptionsList
,
{
provide
,
store
,
});
};
...
...
@@ -19,6 +30,8 @@ describe('SubscriptionsList', () => {
const
findGlEmptyState
=
()
=>
wrapper
.
findComponent
(
GlEmptyState
);
const
findGlTable
=
()
=>
wrapper
.
findComponent
(
GlTable
);
const
findUnlinkButton
=
()
=>
findGlTable
().
findComponent
(
GlButton
);
const
clickUnlinkButton
=
()
=>
findUnlinkButton
().
trigger
(
'
click
'
);
describe
(
'
template
'
,
()
=>
{
it
(
'
renders GlEmptyState when subscriptions is empty
'
,
()
=>
{
...
...
@@ -39,4 +52,71 @@ describe('SubscriptionsList', () => {
expect
(
findGlTable
().
exists
()).
toBe
(
true
);
});
});
describe
(
'
on "Unlink" button click
'
,
()
=>
{
let
removeSubscriptionSpy
;
beforeEach
(()
=>
{
createComponent
({
mountFn
:
mount
,
provide
:
{
subscriptions
:
[
mockSubscription
],
},
});
removeSubscriptionSpy
=
jest
.
spyOn
(
JiraConnectApi
,
'
removeSubscription
'
).
mockResolvedValue
();
});
it
(
'
sets button to loading and sends request
'
,
async
()
=>
{
expect
(
findUnlinkButton
().
props
(
'
loading
'
)).
toBe
(
false
);
clickUnlinkButton
();
await
wrapper
.
vm
.
$nextTick
();
expect
(
findUnlinkButton
().
props
(
'
loading
'
)).
toBe
(
true
);
await
waitForPromises
();
expect
(
removeSubscriptionSpy
).
toHaveBeenCalledWith
(
mockSubscription
.
unlink_path
);
});
describe
(
'
when request is successful
'
,
()
=>
{
it
(
'
reloads the page
'
,
async
()
=>
{
clickUnlinkButton
();
await
waitForPromises
();
expect
(
reloadPage
).
toHaveBeenCalled
();
});
});
describe
(
'
when request has errors
'
,
()
=>
{
const
mockErrorMessage
=
'
error message
'
;
const
mockError
=
{
response
:
{
data
:
{
error
:
mockErrorMessage
}
}
};
beforeEach
(()
=>
{
jest
.
spyOn
(
JiraConnectApi
,
'
removeSubscription
'
).
mockRejectedValue
(
mockError
);
jest
.
spyOn
(
store
,
'
commit
'
);
});
it
(
'
sets alert
'
,
async
()
=>
{
clickUnlinkButton
();
await
waitForPromises
();
expect
(
reloadPage
).
not
.
toHaveBeenCalled
();
expect
(
store
.
commit
.
mock
.
calls
).
toEqual
(
expect
.
arrayContaining
([
[
SET_ALERT
,
{
message
:
mockErrorMessage
,
variant
:
'
danger
'
,
},
],
]),
);
});
});
});
});
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