Skip to content

Commit

Permalink
Add tests for the time difference of start / end and comparisonStart …
Browse files Browse the repository at this point in the history
…/ comparisonEnd
  • Loading branch information
gbamparop committed Mar 14, 2022
1 parent cef8b3f commit ad01aeb
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { TimeRangeComparisonEnum } from '../../../../common/runtime_types/compar
import { getTimeRangeComparison } from './get_time_range_comparison';
import { getDateRange } from '../../../context/url_params_context/helpers';
import { getComparisonOptions } from './get_comparison_options';
import moment from 'moment';

function getExpectedTimesAndComparisons({
rangeFrom,
Expand Down Expand Up @@ -175,6 +176,12 @@ describe('Comparison test suite', () => {
},
]);
});

it('should have the same offset for start / end and comparisonStart / comparisonEnd', () => {
const { start, end, comparisons } = expectation;
const diffInMs = moment(end).diff(moment(start));
expect(`${diffInMs}ms`).toBe(comparisons[0].offset);
});
});

describe('When the time difference is more than 8 days', () => {
Expand Down Expand Up @@ -203,6 +210,12 @@ describe('Comparison test suite', () => {
},
]);
});

it('should have the same offset for start / end and comparisonStart / comparisonEnd', () => {
const { start, end, comparisons } = expectation;
const diffInMs = moment(end).diff(moment(start));
expect(`${diffInMs}ms`).toBe(comparisons[0].offset);
});
});

describe('When "Today" is selected', () => {
Expand Down Expand Up @@ -420,6 +433,12 @@ describe('Comparison test suite', () => {
},
]);
});

it('should have the same offset for start / end and comparisonStart / comparisonEnd', () => {
const { start, end, comparisons } = expectation;
const diffInMs = moment(end).diff(moment(start));
expect(`${diffInMs}ms`).toBe(comparisons[0].offset);
});
});

describe('When "Last 30 days" is selected with rounding', () => {
Expand Down Expand Up @@ -448,5 +467,11 @@ describe('Comparison test suite', () => {
},
]);
});

it('should have the same offset for start / end and comparisonStart / comparisonEnd', () => {
const { start, end, comparisons } = expectation;
const diffInMs = moment(end).diff(moment(start));
expect(`${diffInMs}ms`).toBe(comparisons[0].offset);
});
});
});

0 comments on commit ad01aeb

Please sign in to comment.