UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

101 lines (100 loc) 4.58 kB
/** * DevExtreme (cjs/__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/ */ "use strict"; var _globals = require("@jest/globals"); var _appointment_data_accessor = require("../../../scheduler/__mock__/appointment_data_accessor.mock"); var _resource_manager = require("../../../scheduler/__mock__/resource_manager.mock"); var _get_targeted_appointment = require("./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) } }; (0, _globals.describe)("getTargetedAppointment", () => { (0, _globals.it)("should return grid item targeted appointment", () => { (0, _globals.expect)((0, _get_targeted_appointment.getTargetedAppointment)({ itemData: recurringAppointment, info: info, groupIndex: 0 }, _appointment_data_accessor.mockAppointmentDataAccessor, (0, _resource_manager.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) })) }); (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)({ itemData: recurringAppointment, info: info, groupIndex: 5 }, _appointment_data_accessor.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) })) }); (0, _globals.it)("should return agenda item targeted partial dates", () => { (0, _globals.expect)((0, _get_targeted_appointment.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 }, _appointment_data_accessor.mockAppointmentDataAccessor, (0, _resource_manager.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) })) }); (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.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 }, _appointment_data_accessor.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) })) }) });