UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

65 lines (64 loc) 2.1 kB
/** * DevExtreme (esm/__internal/scheduler/view_model/common/shift_intervals.test.js) * Version: 25.2.5 * Build date: Fri Feb 20 2026 * * Copyright (c) 2012 - 2026 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: Date.UTC(2e3, 0, 10, 0, 6), max: Date.UTC(2e3, 0, 10, 23, 54) }, { min: Date.UTC(2e3, 0, 11, 0, 6), max: Date.UTC(2e3, 0, 11, 23, 54) }, { min: Date.UTC(2e3, 0, 12, 0, 6), max: Date.UTC(2e3, 0, 12, 23, 54) }, { min: Date.UTC(2e3, 0, 13, 0, 6), max: Date.UTC(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: Date.UTC(2e3, 0, 10, 12, 46), max: Date.UTC(2e3, 0, 11, 12, 34) }, { min: Date.UTC(2e3, 0, 11, 12, 46), max: Date.UTC(2e3, 0, 12, 12, 34) }, { min: Date.UTC(2e3, 0, 12, 12, 46), max: Date.UTC(2e3, 0, 13, 12, 34) }, { min: Date.UTC(2e3, 0, 13, 12, 46), max: Date.UTC(2e3, 0, 14, 12, 34) }]) })); it("should shift intervals by offset -760 min", (() => { expect(shiftIntervals(intervals, -456e5)).toEqual([{ min: Date.UTC(2e3, 0, 9, 11, 26), max: Date.UTC(2e3, 0, 10, 11, 14) }, { min: Date.UTC(2e3, 0, 10, 11, 26), max: Date.UTC(2e3, 0, 11, 11, 14) }, { min: Date.UTC(2e3, 0, 11, 11, 26), max: Date.UTC(2e3, 0, 12, 11, 14) }, { min: Date.UTC(2e3, 0, 12, 11, 26), max: Date.UTC(2e3, 0, 13, 11, 14) }]) })) }));