UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

65 lines (64 loc) 2.12 kB
/** * DevExtreme (esm/__internal/scheduler/appointments/data_provider/utils/shiftIntervals.test.js) * Version: 25.1.4 * Build date: Tue Aug 05 2025 * * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import { describe, expect, it } from "@jest/globals"; import { shiftIntervals } from "./shift_intervals"; const intervals = [{ min: new Date(2e3, 0, 10, 0, 6), max: new Date(2e3, 0, 10, 23, 54) }, { min: new Date(2e3, 0, 11, 0, 6), max: new Date(2e3, 0, 11, 23, 54) }, { min: new Date(2e3, 0, 12, 0, 6), max: new Date(2e3, 0, 12, 23, 54) }, { min: new Date(2e3, 0, 13, 0, 6), max: new Date(2e3, 0, 13, 23, 54) }]; describe("getVisibleDateTimeIntervals", (() => { it("should shift intervals by offset 0", (() => { expect(shiftIntervals(intervals, 0)).toEqual(intervals) })); it("should shift intervals by offset 760 min", (() => { expect(shiftIntervals(intervals, 456e5)).toEqual([{ min: new Date(2e3, 0, 10, 12, 46), max: new Date(2e3, 0, 11, 12, 34) }, { min: new Date(2e3, 0, 11, 12, 46), max: new Date(2e3, 0, 12, 12, 34) }, { min: new Date(2e3, 0, 12, 12, 46), max: new Date(2e3, 0, 13, 12, 34) }, { min: new Date(2e3, 0, 13, 12, 46), max: new Date(2e3, 0, 14, 12, 34) }]) })); it("should shift intervals by offset -760 min", (() => { expect(shiftIntervals(intervals, -456e5)).toEqual([{ min: new Date(2e3, 0, 9, 11, 26), max: new Date(2e3, 0, 10, 11, 14) }, { min: new Date(2e3, 0, 10, 11, 26), max: new Date(2e3, 0, 11, 11, 14) }, { min: new Date(2e3, 0, 11, 11, 26), max: new Date(2e3, 0, 12, 11, 14) }, { min: new Date(2e3, 0, 12, 11, 26), max: new Date(2e3, 0, 13, 11, 14) }]) })) }));