devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
117 lines (116 loc) • 4.57 kB
JavaScript
/**
* DevExtreme (esm/__internal/scheduler/utils/get_targeted_appointment.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 {
getResourceManagerMock
} from "../../scheduler/__mock__/resource_manager.mock";
import {
mockUppercaseFieldExpressions
} from "../__mock__/appointment_data_accessor.mock";
import {
AppointmentDataAccessor
} from "./data_accessor/appointment_data_accessor";
import {
getTargetedAppointment,
getTargetedAppointmentFromInfo
} from "./get_targeted_appointment";
const dataAccessor = new AppointmentDataAccessor(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)
}
};
describe("getTargetedAppointment", (() => {
it("should return collector targeted appointment", (() => {
expect(getTargetedAppointment(appointment, {}, dataAccessor, getResourceManagerMock())).toEqual(Object.assign({}, appointment, {
displayStartDate: new Date(200, 0, 0),
displayEndDate: new Date(200, 0, 1)
}))
}));
it("should return grid item targeted appointment", (() => {
expect(getTargetedAppointment(appointmentRecurrence, {
info: info,
groupIndex: 0
}, dataAccessor, 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)
}))
}));
it("should return grid item targeted appointment with resources", (async () => {
const resourceManager = getResourceManagerMock();
await resourceManager.loadGroupResources(["roomId", "assigneeId"]);
expect(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)
}))
}));
it("should return agenda item targeted partial dates", (() => {
expect(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, 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)
}))
}));
it("should return agenda item targeted partial dates with resources", (async () => {
const resourceManager = getResourceManagerMock();
await resourceManager.loadGroupResources(["roomId", "assigneeId"]);
expect(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)
}))
}))
}));