UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

113 lines (112 loc) 4.13 kB
/** * DevExtreme (cjs/__internal/scheduler/view_model/common/split_interval_by_days.test.js) * Version: 25.2.7 * Build date: Tue May 05 2026 * * Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ "use strict"; var _globals = require("@jest/globals"); var _split_interval_by_days = require("./split_interval_by_days"); (0, _globals.describe)("splitIntervalByDay", () => { (0, _globals.it)("should return one interval for one day", () => { (0, _globals.expect)((0, _split_interval_by_days.splitIntervalByDay)({ startDayHour: 0, endDayHour: 24, min: Date.UTC(2e3, 0, 10), max: Date.UTC(2e3, 0, 11), skippedDays: [] })).toEqual([{ min: Date.UTC(2e3, 0, 10), max: Date.UTC(2e3, 0, 11) }]) }); (0, _globals.it)("should return day by day intervals", () => { (0, _globals.expect)((0, _split_interval_by_days.splitIntervalByDay)({ startDayHour: 0, endDayHour: 24, min: Date.UTC(2e3, 0, 10), max: Date.UTC(2e3, 0, 13), skippedDays: [] })).toEqual([{ min: Date.UTC(2e3, 0, 10), max: Date.UTC(2e3, 0, 11) }, { min: Date.UTC(2e3, 0, 11), max: Date.UTC(2e3, 0, 12) }, { min: Date.UTC(2e3, 0, 12), max: Date.UTC(2e3, 0, 13) }]) }); (0, _globals.it)("should return day by day intervals for [3, 13]", () => { (0, _globals.expect)((0, _split_interval_by_days.splitIntervalByDay)({ startDayHour: 3, endDayHour: 13, min: Date.UTC(2e3, 0, 10), max: Date.UTC(2e3, 0, 13), skippedDays: [] })).toEqual([{ min: Date.UTC(2e3, 0, 10, 3), max: Date.UTC(2e3, 0, 10, 13) }, { min: Date.UTC(2e3, 0, 11, 3), max: Date.UTC(2e3, 0, 11, 13) }, { min: Date.UTC(2e3, 0, 12, 3), max: Date.UTC(2e3, 0, 12, 13) }]) }); (0, _globals.it)("should return day by day intervals for [0.1, 23.9]", () => { (0, _globals.expect)((0, _split_interval_by_days.splitIntervalByDay)({ startDayHour: .1, endDayHour: 23.9, min: Date.UTC(2e3, 0, 10, 0, 6), max: Date.UTC(2e3, 0, 13, 23, 56), skippedDays: [] })).toEqual([{ 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) }]) }); (0, _globals.it)("should return zero intervals for interacted hours", () => { (0, _globals.expect)((0, _split_interval_by_days.splitIntervalByDay)({ startDayHour: 20, endDayHour: 10, min: Date.UTC(2e3, 0, 10, 10), max: Date.UTC(2e3, 0, 15, 5), skippedDays: [] })).toEqual([]) }); (0, _globals.it)("should return intervals without skipped days", () => { (0, _globals.expect)((0, _split_interval_by_days.splitIntervalByDay)({ startDayHour: 0, endDayHour: 24, min: Date.UTC(2e3, 2, 1), max: Date.UTC(2e3, 2, 7), skippedDays: [0, 6] })).toEqual([{ min: Date.UTC(2e3, 2, 1), max: Date.UTC(2e3, 2, 2) }, { min: Date.UTC(2e3, 2, 2), max: Date.UTC(2e3, 2, 3) }, { min: Date.UTC(2e3, 2, 3), max: Date.UTC(2e3, 2, 4) }, { min: Date.UTC(2e3, 2, 6), max: Date.UTC(2e3, 2, 7) }]) }) });