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';
...
@@ -22,11 +22,7 @@ const FIXTURE = 'services/edit_service.html';
describe
(
'
IntegrationSettingsForm
'
,
()
=>
{
describe
(
'
IntegrationSettingsForm
'
,
()
=>
{
let
integrationSettingsForm
;
let
integrationSettingsForm
;
const
mockVuexDispatch
=
()
=>
{
const
mockStoreDispatch
=
()
=>
jest
.
spyOn
(
integrationSettingsForm
.
vue
.
$store
,
'
dispatch
'
);
const
dispatchSpy
=
jest
.
fn
();
integrationSettingsForm
.
vue
.
$store
=
{
dispatch
:
dispatchSpy
};
return
dispatchSpy
;
};
beforeEach
(()
=>
{
beforeEach
(()
=>
{
loadFixtures
(
FIXTURE
);
loadFixtures
(
FIXTURE
);
...
@@ -130,7 +126,7 @@ describe('IntegrationSettingsForm', () => {
...
@@ -130,7 +126,7 @@ describe('IntegrationSettingsForm', () => {
});
});
it
(
'
should always dispatch `setIsTesting` with `false` once request is completed
'
,
async
()
=>
{
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
();
mockAxios
.
onPut
(
integrationSettingsForm
.
testEndPoint
).
networkError
();
eventHub
.
$emit
(
TEST_INTEGRATION_EVENT
);
eventHub
.
$emit
(
TEST_INTEGRATION_EVENT
);
...
@@ -147,7 +143,7 @@ describe('IntegrationSettingsForm', () => {
...
@@ -147,7 +143,7 @@ describe('IntegrationSettingsForm', () => {
});
});
it
(
'
should dispatch `setIsTesting` with `false` and not call `testSettings`
'
,
async
()
=>
{
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
);
eventHub
.
$emit
(
TEST_INTEGRATION_EVENT
);
await
waitForPromises
();
await
waitForPromises
();
...
@@ -160,7 +156,7 @@ describe('IntegrationSettingsForm', () => {
...
@@ -160,7 +156,7 @@ describe('IntegrationSettingsForm', () => {
describe
(
'
when event hub receives `GET_JIRA_ISSUE_TYPES_EVENT`
'
,
()
=>
{
describe
(
'
when event hub receives `GET_JIRA_ISSUE_TYPES_EVENT`
'
,
()
=>
{
it
(
'
should always dispatch `requestJiraIssueTypes`
'
,
()
=>
{
it
(
'
should always dispatch `requestJiraIssueTypes`
'
,
()
=>
{
const
dispatchSpy
=
mock
Vuex
Dispatch
();
const
dispatchSpy
=
mock
Store
Dispatch
();
mockAxios
.
onPut
(
integrationSettingsForm
.
testEndPoint
).
networkError
();
mockAxios
.
onPut
(
integrationSettingsForm
.
testEndPoint
).
networkError
();
eventHub
.
$emit
(
GET_JIRA_ISSUE_TYPES_EVENT
);
eventHub
.
$emit
(
GET_JIRA_ISSUE_TYPES_EVENT
);
...
@@ -178,7 +174,7 @@ describe('IntegrationSettingsForm', () => {
...
@@ -178,7 +174,7 @@ describe('IntegrationSettingsForm', () => {
});
});
it
(
'
should dispatch `receiveJiraIssueTypesSuccess` with the correct payload if ajax request is successful
'
,
async
()
=>
{
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
'
];
const
mockData
=
[
'
ISSUE
'
,
'
EPIC
'
];
mockAxios
.
onPut
(
integrationSettingsForm
.
testEndPoint
).
reply
(
200
,
{
mockAxios
.
onPut
(
integrationSettingsForm
.
testEndPoint
).
reply
(
200
,
{
error
:
false
,
error
:
false
,
...
@@ -194,7 +190,7 @@ describe('IntegrationSettingsForm', () => {
...
@@ -194,7 +190,7 @@ describe('IntegrationSettingsForm', () => {
it
.
each
([
'
Custom error message here
'
,
undefined
])(
it
.
each
([
'
Custom error message here
'
,
undefined
])(
'
should dispatch "receiveJiraIssueTypesError" with a message if the backend responds with error
'
,
'
should dispatch "receiveJiraIssueTypesError" with a message if the backend responds with error
'
,
async
(
responseErrorMessage
)
=>
{
async
(
responseErrorMessage
)
=>
{
const
dispatchSpy
=
mock
Vuex
Dispatch
();
const
dispatchSpy
=
mock
Store
Dispatch
();
const
expectedErrorMessage
=
const
expectedErrorMessage
=
responseErrorMessage
||
I18N_FETCH_TEST_SETTINGS_DEFAULT_ERROR_MESSAGE
;
responseErrorMessage
||
I18N_FETCH_TEST_SETTINGS_DEFAULT_ERROR_MESSAGE
;
...
@@ -237,7 +233,7 @@ describe('IntegrationSettingsForm', () => {
...
@@ -237,7 +233,7 @@ describe('IntegrationSettingsForm', () => {
});
});
it
(
'
should dispatch `setIsSaving` with `false` and not submit form
'
,
async
()
=>
{
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
);
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