devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
71 lines (70 loc) • 2.31 kB
JavaScript
/**
* DevExtreme (esm/__internal/scheduler/view_model/preparation/prepare_appointments.test.js)
* Version: 25.2.8
* Build date: Mon Jun 08 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 {
mockAppointmentDataAccessor
} from "../../../scheduler/__mock__/appointment_data_accessor.mock";
import {
createTimeZoneCalculator
} from "../../r1/timezone_calculator";
import {
prepareAppointments
} from "./prepare_appointments";
const schedulerMock = {
currentView: {
type: "agenda"
},
getViewOption: name => ({
cellDuration: 30,
allDayPanelMode: "all"
} [name]),
_dataAccessors: mockAppointmentDataAccessor,
timeZoneCalculator: createTimeZoneCalculator("")
};
describe("prepareAppointments", () => {
it("should return empty array if no dataItems", () => {
let result = prepareAppointments(schedulerMock, void 0);
expect(result).toEqual([]);
result = prepareAppointments(schedulerMock, []);
expect(result).toEqual([])
});
it("should return empty array without startDate", () => {
const data = [{
endDate: new Date(2021, 9, 9)
}];
const result = prepareAppointments(schedulerMock, data);
expect(result).toEqual([])
});
it("should correct endDate value if it doesn't set", () => {
const data = [{
startDate: new Date(2021, 9, 9, 17)
}];
const expectedResult = {
allDay: false,
source: {
startDate: data[0].startDate.getTime(),
endDate: data[0].startDate.getTime() + 18e5
},
hasRecurrenceRule: false,
itemData: Object.assign({}, data[0], {
endDate: new Date(2021, 9, 9, 17, 30)
}),
recurrenceException: void 0,
recurrenceRule: void 0,
visible: true,
disabled: false
};
const result = prepareAppointments(schedulerMock, data);
expect(result).toEqual([expectedResult])
})
});