grafana/public/app/plugins/datasource/loki/metricTimeSplitting.test.ts
Matias Chomicki 663ed7ba82
Loki Query Splitting: Rename from "chunk" to "splitting" (#65630)
* Update chunking mentions in the code and ui

* Rename files and exported functions

* Rename configuration attribute

* Rename grouped querying function name

* Update more function names

* Update unit test

* Update unit tests

* More renames

* Rename time splitting functions
2023-04-03 12:30:08 +00:00

23 lines
914 B
TypeScript

import { splitTimeRange } from './metricTimeSplitting';
describe('metric splitTimeRange', () => {
it('should split time range into chunks', () => {
const start = Date.parse('2022-02-06T14:10:03');
const end = Date.parse('2022-02-06T14:11:03');
const step = 10 * 1000;
expect(splitTimeRange(start, end, step, 25000)).toStrictEqual([
[Date.parse('2022-02-06T14:10:00'), Date.parse('2022-02-06T14:10:10')],
[Date.parse('2022-02-06T14:10:20'), Date.parse('2022-02-06T14:10:40')],
[Date.parse('2022-02-06T14:10:50'), Date.parse('2022-02-06T14:11:10')],
]);
});
it('should return the original interval if requested duration is smaller than step', () => {
const start = Date.parse('2022-02-06T14:10:03');
const end = Date.parse('2022-02-06T14:10:33');
const step = 10 * 1000;
expect(splitTimeRange(start, end, step, 1000)).toEqual([[start, end]]);
});
});