Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/monitoring/store/utils_spec.js')
-rw-r--r--spec/frontend/monitoring/store/utils_spec.js31
1 files changed, 27 insertions, 4 deletions
diff --git a/spec/frontend/monitoring/store/utils_spec.js b/spec/frontend/monitoring/store/utils_spec.js
index f46409e8e32..7ee2a16b4bd 100644
--- a/spec/frontend/monitoring/store/utils_spec.js
+++ b/spec/frontend/monitoring/store/utils_spec.js
@@ -2,9 +2,11 @@ import { SUPPORTED_FORMATS } from '~/lib/utils/unit_format';
import {
uniqMetricsId,
parseEnvironmentsResponse,
+ parseAnnotationsResponse,
removeLeadingSlash,
mapToDashboardViewModel,
} from '~/monitoring/stores/utils';
+import { annotationsData } from '../mock_data';
import { NOT_IN_DB_PREFIX } from '~/monitoring/constants';
const projectPath = 'gitlab-org/gitlab-test';
@@ -56,7 +58,7 @@ describe('mapToDashboardViewModel', () => {
y_label: 'Y Label A',
yAxis: {
name: 'Y Label A',
- format: 'number',
+ format: 'engineering',
precision: 2,
},
metrics: [],
@@ -138,7 +140,7 @@ describe('mapToDashboardViewModel', () => {
y_label: '',
yAxis: {
name: '',
- format: SUPPORTED_FORMATS.number,
+ format: SUPPORTED_FORMATS.engineering,
precision: 2,
},
metrics: [],
@@ -159,7 +161,7 @@ describe('mapToDashboardViewModel', () => {
},
yAxis: {
name: '',
- format: SUPPORTED_FORMATS.number,
+ format: SUPPORTED_FORMATS.engineering,
precision: 2,
},
metrics: [],
@@ -219,7 +221,7 @@ describe('mapToDashboardViewModel', () => {
},
});
- expect(getMappedPanel().yAxis.format).toBe(SUPPORTED_FORMATS.number);
+ expect(getMappedPanel().yAxis.format).toBe(SUPPORTED_FORMATS.engineering);
});
// This property allows single_stat panels to render percentile values
@@ -376,6 +378,27 @@ describe('parseEnvironmentsResponse', () => {
});
});
+describe('parseAnnotationsResponse', () => {
+ const parsedAnnotationResponse = [
+ {
+ description: 'This is a test annotation',
+ endingAt: null,
+ id: 'gid://gitlab/Metrics::Dashboard::Annotation/1',
+ panelId: null,
+ startingAt: new Date('2020-04-12T12:51:53.000Z'),
+ },
+ ];
+ it.each`
+ case | input | expected
+ ${'Returns empty array for null input'} | ${null} | ${[]}
+ ${'Returns empty array for undefined input'} | ${undefined} | ${[]}
+ ${'Returns empty array for empty input'} | ${[]} | ${[]}
+ ${'Returns parsed responses for annotations data'} | ${[annotationsData[0]]} | ${parsedAnnotationResponse}
+ `('$case', ({ input, expected }) => {
+ expect(parseAnnotationsResponse(input)).toEqual(expected);
+ });
+});
+
describe('removeLeadingSlash', () => {
[
{ input: null, output: '' },