grafana/public/app/core/utils/timeRegions.test.ts
renovate[bot] e84a01e870
Update jest monorepo to v29 (#58261)
* Update jest monorepo to v29

* update snapshots + wrap test in act

* fix linting errors: jest.mocked now defaults to deep mocking

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
2022-11-24 14:00:41 +00:00

44 lines
1.0 KiB
TypeScript

import { dateTime, TimeRange } from '@grafana/data';
import { calculateTimesWithin, TimeRegionConfig } from './timeRegions';
describe('timeRegions', () => {
describe('day of week', () => {
it('4 sundays in january 2021', () => {
const cfg: TimeRegionConfig = {
fromDayOfWeek: 1,
from: '12:00',
};
const tr: TimeRange = {
from: dateTime('2021-01-00', 'YYYY-MM-dd'),
to: dateTime('2021-02-00', 'YYYY-MM-dd'),
raw: {
to: '',
from: '',
},
};
const regions = calculateTimesWithin(cfg, tr);
expect(regions).toMatchInlineSnapshot(`
[
{
"from": 1609779600000,
"to": 1609779600000,
},
{
"from": 1610384400000,
"to": 1610384400000,
},
{
"from": 1610989200000,
"to": 1610989200000,
},
{
"from": 1611594000000,
"to": 1611594000000,
},
]
`);
});
});
});