blob: 790854d0ca76bc807959f4a8fcf790615edbf3a0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
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({});
});
});
|