devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
105 lines (104 loc) • 4.96 kB
JavaScript
/**
* DevExtreme (cjs/__internal/scheduler/utils/get_targeted_appointment.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 _resource_manager = require("../../scheduler/__mock__/resource_manager.mock");
var _appointment_data_accessor = require("../__mock__/appointment_data_accessor.mock");
var _appointment_data_accessor2 = require("./data_accessor/appointment_data_accessor");
var _get_targeted_appointment = require("./get_targeted_appointment");
const dataAccessor = new _appointment_data_accessor2.AppointmentDataAccessor(_appointment_data_accessor.mockUppercaseFieldExpressions, true);
const appointment = {
StartDate: new Date(200, 0, 0),
EndDate: new Date(200, 0, 1)
};
const appointmentRecurrence = Object.assign({}, appointment, {
RecurrenceRule: "FREQ=DAILY"
});
const info = {
sourceAppointment: {
startDate: new Date(200, 0, 5),
endDate: new Date(200, 0, 6)
},
appointment: {
startDate: new Date(200, 0, 5, 10),
endDate: new Date(200, 0, 6, 11)
}
};
(0, _globals.describe)("getTargetedAppointment", () => {
(0, _globals.it)("should return collector targeted appointment", () => {
(0, _globals.expect)((0, _get_targeted_appointment.getTargetedAppointment)(appointment, {}, dataAccessor, (0, _resource_manager.getResourceManagerMock)())).toEqual(Object.assign({}, appointment, {
displayStartDate: new Date(200, 0, 0),
displayEndDate: new Date(200, 0, 1)
}))
});
(0, _globals.it)("should return grid item targeted appointment", () => {
(0, _globals.expect)((0, _get_targeted_appointment.getTargetedAppointment)(appointmentRecurrence, {
info: info,
groupIndex: 0
}, dataAccessor, (0, _resource_manager.getResourceManagerMock)())).toEqual(Object.assign({}, appointmentRecurrence, {
StartDate: new Date(200, 0, 5),
EndDate: new Date(200, 0, 6),
displayStartDate: new Date(200, 0, 5, 10),
displayEndDate: new Date(200, 0, 6, 11)
}))
});
(0, _globals.it)("should return grid item targeted appointment with resources", async () => {
const resourceManager = (0, _resource_manager.getResourceManagerMock)();
await resourceManager.loadGroupResources(["roomId", "assigneeId"]);
(0, _globals.expect)((0, _get_targeted_appointment.getTargetedAppointment)(appointmentRecurrence, {
info: info,
groupIndex: 5
}, dataAccessor, resourceManager)).toEqual(Object.assign({}, appointmentRecurrence, {
assigneeId: [2],
roomId: 1,
StartDate: new Date(200, 0, 5),
EndDate: new Date(200, 0, 6),
displayStartDate: new Date(200, 0, 5, 10),
displayEndDate: new Date(200, 0, 6, 11)
}))
});
(0, _globals.it)("should return agenda item targeted partial dates", () => {
(0, _globals.expect)((0, _get_targeted_appointment.getTargetedAppointmentFromInfo)(appointmentRecurrence, {
isAgendaModel: true,
info: Object.assign({}, info, {
partialDates: {
startDate: new Date(200, 0, 5, 3),
endDate: new Date(200, 0, 7)
}
}),
groupIndex: 0
}, dataAccessor, (0, _resource_manager.getResourceManagerMock)(), true)).toEqual(Object.assign({}, appointmentRecurrence, {
StartDate: new Date(200, 0, 5),
EndDate: new Date(200, 0, 6),
displayStartDate: new Date(200, 0, 5, 3),
displayEndDate: new Date(200, 0, 7)
}))
});
(0, _globals.it)("should return agenda item targeted partial dates with resources", async () => {
const resourceManager = (0, _resource_manager.getResourceManagerMock)();
await resourceManager.loadGroupResources(["roomId", "assigneeId"]);
(0, _globals.expect)((0, _get_targeted_appointment.getTargetedAppointmentFromInfo)(appointment, {
isAgendaModel: true,
info: Object.assign({}, info, {
partialDates: {
startDate: new Date(200, 0, 5, 3),
endDate: new Date(200, 0, 7)
}
}),
groupIndex: 3
}, dataAccessor, resourceManager, true)).toEqual(Object.assign({}, appointment, {
assigneeId: [4],
roomId: 0,
StartDate: new Date(200, 0, 5),
EndDate: new Date(200, 0, 6),
displayStartDate: new Date(200, 0, 5, 3),
displayEndDate: new Date(200, 0, 7)
}))
})
});