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
a7e73ed0
Commit
a7e73ed0
authored
Oct 26, 2021
by
Tom Quirk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address reviewer feedback
Improve store dispatch mock function
parent
32d6f322
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
11 deletions
+7
-11
spec/frontend/integrations/integration_settings_form_spec.js
spec/frontend/integrations/integration_settings_form_spec.js
+7
-11
No files found.
spec/frontend/integrations/integration_settings_form_spec.js
View file @
a7e73ed0
...
...
@@ -22,11 +22,7 @@ const FIXTURE = 'services/edit_service.html';
describe
(
'
IntegrationSettingsForm
'
,
()
=>
{
let
integrationSettingsForm
;
const
mockVuexDispatch
=
()
=>
{
const
dispatchSpy
=
jest
.
fn
();
integrationSettingsForm
.
vue
.
$store
=
{
dispatch
:
dispatchSpy
};
return
dispatchSpy
;
};
const
mockStoreDispatch
=
()
=>
jest
.
spyOn
(
integrationSettingsForm
.
vue
.
$store
,
'
dispatch
'
);
beforeEach
(()
=>
{
loadFixtures
(
FIXTURE
);
...
...
@@ -130,7 +126,7 @@ describe('IntegrationSettingsForm', () => {
});
it
(
'
should always dispatch `setIsTesting` with `false` once request is completed
'
,
async
()
=>
{
const
dispatchSpy
=
mock
Vuex
Dispatch
();
const
dispatchSpy
=
mock
Store
Dispatch
();
mockAxios
.
onPut
(
integrationSettingsForm
.
testEndPoint
).
networkError
();
eventHub
.
$emit
(
TEST_INTEGRATION_EVENT
);
...
...
@@ -147,7 +143,7 @@ describe('IntegrationSettingsForm', () => {
});
it
(
'
should dispatch `setIsTesting` with `false` and not call `testSettings`
'
,
async
()
=>
{
const
dispatchSpy
=
mock
Vuex
Dispatch
();
const
dispatchSpy
=
mock
Store
Dispatch
();
eventHub
.
$emit
(
TEST_INTEGRATION_EVENT
);
await
waitForPromises
();
...
...
@@ -160,7 +156,7 @@ describe('IntegrationSettingsForm', () => {
describe
(
'
when event hub receives `GET_JIRA_ISSUE_TYPES_EVENT`
'
,
()
=>
{
it
(
'
should always dispatch `requestJiraIssueTypes`
'
,
()
=>
{
const
dispatchSpy
=
mock
Vuex
Dispatch
();
const
dispatchSpy
=
mock
Store
Dispatch
();
mockAxios
.
onPut
(
integrationSettingsForm
.
testEndPoint
).
networkError
();
eventHub
.
$emit
(
GET_JIRA_ISSUE_TYPES_EVENT
);
...
...
@@ -178,7 +174,7 @@ describe('IntegrationSettingsForm', () => {
});
it
(
'
should dispatch `receiveJiraIssueTypesSuccess` with the correct payload if ajax request is successful
'
,
async
()
=>
{
const
dispatchSpy
=
mock
Vuex
Dispatch
();
const
dispatchSpy
=
mock
Store
Dispatch
();
const
mockData
=
[
'
ISSUE
'
,
'
EPIC
'
];
mockAxios
.
onPut
(
integrationSettingsForm
.
testEndPoint
).
reply
(
200
,
{
error
:
false
,
...
...
@@ -194,7 +190,7 @@ describe('IntegrationSettingsForm', () => {
it
.
each
([
'
Custom error message here
'
,
undefined
])(
'
should dispatch "receiveJiraIssueTypesError" with a message if the backend responds with error
'
,
async
(
responseErrorMessage
)
=>
{
const
dispatchSpy
=
mock
Vuex
Dispatch
();
const
dispatchSpy
=
mock
Store
Dispatch
();
const
expectedErrorMessage
=
responseErrorMessage
||
I18N_FETCH_TEST_SETTINGS_DEFAULT_ERROR_MESSAGE
;
...
...
@@ -237,7 +233,7 @@ describe('IntegrationSettingsForm', () => {
});
it
(
'
should dispatch `setIsSaving` with `false` and not submit form
'
,
async
()
=>
{
const
dispatchSpy
=
mock
Vuex
Dispatch
();
const
dispatchSpy
=
mock
Store
Dispatch
();
eventHub
.
$emit
(
SAVE_INTEGRATION_EVENT
);
...
...
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