Commit d134ef84 authored by Sean Arnold's avatar Sean Arnold

Add alert metric images service spec

parent ea6abdb8
......@@ -6,7 +6,7 @@ import {
} from '~/rest_api';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
function replaceModelIId(payload) {
function replaceModelIId(payload = {}) {
delete Object.assign(payload, { alertIid: payload.modelIid }).modelIid;
return payload;
}
......
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({});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment