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
d134ef84
Commit
d134ef84
authored
Apr 12, 2022
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add alert metric images service spec
parent
ea6abdb8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
1 deletion
+45
-1
app/assets/javascripts/vue_shared/alert_details/service.js
app/assets/javascripts/vue_shared/alert_details/service.js
+1
-1
spec/frontend/vue_shared/alert_details/service_spec.js
spec/frontend/vue_shared/alert_details/service_spec.js
+44
-0
No files found.
app/assets/javascripts/vue_shared/alert_details/service.js
View file @
d134ef84
...
@@ -6,7 +6,7 @@ import {
...
@@ -6,7 +6,7 @@ import {
}
from
'
~/rest_api
'
;
}
from
'
~/rest_api
'
;
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
function
replaceModelIId
(
payload
)
{
function
replaceModelIId
(
payload
=
{}
)
{
delete
Object
.
assign
(
payload
,
{
alertIid
:
payload
.
modelIid
}).
modelIid
;
delete
Object
.
assign
(
payload
,
{
alertIid
:
payload
.
modelIid
}).
modelIid
;
return
payload
;
return
payload
;
}
}
...
...
spec/frontend/vue_shared/alert_details/service_spec.js
0 → 100644
View file @
d134ef84
import
{
fileList
,
fileListRaw
}
from
'
jest/vue_shared/components/metric_images/mock_data
'
;
import
{
getMetricImages
,
uploadMetricImage
,
updateMetricImage
,
deleteMetricImage
,
}
from
'
~/vue_shared/alert_details/service
'
;
import
*
as
alertManagementAlertsApi
from
'
~/api/alert_management_alerts_api
'
;
jest
.
mock
(
'
~/api/alert_management_alerts_api
'
);
describe
(
'
Alert details service
'
,
()
=>
{
it
(
'
fetches metric images
'
,
async
()
=>
{
alertManagementAlertsApi
.
fetchAlertMetricImages
.
mockResolvedValue
({
data
:
fileListRaw
});
const
result
=
await
getMetricImages
();
expect
(
alertManagementAlertsApi
.
fetchAlertMetricImages
).
toHaveBeenCalled
();
expect
(
result
).
toEqual
(
fileList
);
});
it
(
'
uploads a metric image
'
,
async
()
=>
{
alertManagementAlertsApi
.
uploadAlertMetricImage
.
mockResolvedValue
({
data
:
fileListRaw
[
0
]
});
const
result
=
await
uploadMetricImage
();
expect
(
alertManagementAlertsApi
.
uploadAlertMetricImage
).
toHaveBeenCalled
();
expect
(
result
).
toEqual
(
fileList
[
0
]);
});
it
(
'
updates a metric image
'
,
async
()
=>
{
alertManagementAlertsApi
.
updateAlertMetricImage
.
mockResolvedValue
({
data
:
fileListRaw
[
0
]
});
const
result
=
await
updateMetricImage
();
expect
(
alertManagementAlertsApi
.
updateAlertMetricImage
).
toHaveBeenCalled
();
expect
(
result
).
toEqual
(
fileList
[
0
]);
});
it
(
'
deletes a metric image
'
,
async
()
=>
{
alertManagementAlertsApi
.
deleteAlertMetricImage
.
mockResolvedValue
({
data
:
''
});
const
result
=
await
deleteMetricImage
();
expect
(
alertManagementAlertsApi
.
deleteAlertMetricImage
).
toHaveBeenCalled
();
expect
(
result
).
toEqual
({});
});
});
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