devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
110 lines (109 loc) • 4.17 kB
JavaScript
/**
* DevExtreme (esm/__internal/scheduler/appointments_new/utils/get_targeted_appointment.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 {
getResourceManagerMock
} from "../../../scheduler/__mock__/resource_manager.mock";
import {
getTargetedAppointment
} from "./get_targeted_appointment";
const appointment = {
startDate: new Date(200, 0, 0),
endDate: new Date(200, 0, 1)
};
const recurringAppointment = 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 grid item targeted appointment", () => {
expect(getTargetedAppointment({
itemData: recurringAppointment,
info: info,
groupIndex: 0
}, mockAppointmentDataAccessor, getResourceManagerMock([]))).toEqual(Object.assign({}, recurringAppointment, {
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({
itemData: recurringAppointment,
info: info,
groupIndex: 5
}, mockAppointmentDataAccessor, resourceManager)).toEqual(Object.assign({}, recurringAppointment, {
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(getTargetedAppointment({
isAgendaModel: true,
itemData: recurringAppointment,
info: Object.assign({}, info, {
partialDates: {
startDate: new Date(200, 0, 5, 3),
endDate: new Date(200, 0, 7)
}
}),
groupIndex: 0
}, mockAppointmentDataAccessor, getResourceManagerMock([]))).toEqual(Object.assign({}, recurringAppointment, {
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(getTargetedAppointment({
isAgendaModel: true,
itemData: appointment,
info: Object.assign({}, info, {
partialDates: {
startDate: new Date(200, 0, 5, 3),
endDate: new Date(200, 0, 7)
}
}),
groupIndex: 3
}, mockAppointmentDataAccessor, resourceManager)).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)
}))
})
});