devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
136 lines (134 loc) • 7.34 kB
JavaScript
/**
* DevExtreme (cjs/__internal/scheduler/appointments_new/appointment_collector.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 _renderer = _interopRequireDefault(require("../../../core/renderer"));
var _fx = _interopRequireDefault(require("../../../common/core/animation/fx"));
var _appointment_collector = require("./__mock__/appointment_collector");
var _const = require("./const");
function _interopRequireDefault(e) {
return e && e.__esModule ? e : {
default: e
}
}
const defaultAppointmentData = {
title: "Test appointment",
startDate: new Date(2024, 0, 1, 9, 0),
endDate: new Date(2024, 0, 1, 10, 0)
};
(0, _globals.describe)("AppointmentCollector", () => {
(0, _globals.beforeEach)(() => {
_fx.default.off = true;
const $container = (0, _renderer.default)("<div>").addClass("container").appendTo(document.body);
(0, _renderer.default)("<div>").addClass("root").appendTo($container)
});
(0, _globals.afterEach)(() => {
(0, _renderer.default)(".container").remove();
_fx.default.off = false;
_globals.jest.useRealTimers()
});
(0, _globals.describe)("Classes", () => {
(0, _globals.it)("should have correct container class", () => {
const instance = (0, _appointment_collector.createAppointmentCollector)((0, _appointment_collector.getAppointmentCollectorProperties)([defaultAppointmentData]));
(0, _globals.expect)(instance.$element().hasClass("dx-scheduler-appointment-collector")).toBe(true);
(0, _globals.expect)(instance.$element().hasClass("dx-button")).toBe(true)
});
(0, _globals.it)("should have correct content class", () => {
const instance = (0, _appointment_collector.createAppointmentCollector)((0, _appointment_collector.getAppointmentCollectorProperties)([defaultAppointmentData]));
const $buttonContent = instance.$element().find(".dx-button-content");
(0, _globals.expect)($buttonContent.hasClass(_const.APPOINTMENT_COLLECTOR_CLASSES.CONTENT)).toBe(true)
});
_globals.it.each([true, false])("should have correct compact class for isCompact = %o", isCompact => {
const instance = (0, _appointment_collector.createAppointmentCollector)(Object.assign({}, (0, _appointment_collector.getAppointmentCollectorProperties)([defaultAppointmentData]), {
isCompact: isCompact
}));
(0, _globals.expect)(instance.$element().hasClass(_const.APPOINTMENT_COLLECTOR_CLASSES.COMPACT)).toBe(isCompact)
})
});
(0, _globals.describe)("Aria", () => {
(0, _globals.it)("should have correct aria-roledescription when appointment is in the same date", () => {
const instance = (0, _appointment_collector.createAppointmentCollector)((0, _appointment_collector.getAppointmentCollectorProperties)([{
text: "test",
startDate: new Date(2024, 0, 1, 9, 0),
endDate: new Date(2024, 0, 1, 10, 0)
}]));
(0, _globals.expect)(instance.$element().attr("aria-roledescription")).toBe("January 1, 2024")
});
(0, _globals.it)("should have correct aria-roledescription when appointment is in different dates", () => {
const instance = (0, _appointment_collector.createAppointmentCollector)((0, _appointment_collector.getAppointmentCollectorProperties)([{
text: "test",
startDate: new Date(2024, 0, 1, 9, 0),
endDate: new Date(2024, 0, 2, 10, 0)
}]));
(0, _globals.expect)(instance.$element().attr("aria-roledescription")).toBe("January 1, 2024 - January 2, 2024")
})
});
(0, _globals.describe)("Geometry", () => {
(0, _globals.it)("should have correct top and left on init", () => {
const instance = (0, _appointment_collector.createAppointmentCollector)(Object.assign({}, (0, _appointment_collector.getAppointmentCollectorProperties)([defaultAppointmentData]), {
geometry: {
top: 100,
left: 200,
height: 30,
width: 40
}
}));
(0, _globals.expect)(instance.$element().css("top")).toBe("100px");
(0, _globals.expect)(instance.$element().css("left")).toBe("200px");
(0, _globals.expect)(instance.$element().css("height")).toBe("30px");
(0, _globals.expect)(instance.$element().css("width")).toBe("40px")
});
(0, _globals.it)("should have correct top and left after geometry is updated and resize is called", () => {
const instance = (0, _appointment_collector.createAppointmentCollector)(Object.assign({}, (0, _appointment_collector.getAppointmentCollectorProperties)([defaultAppointmentData]), {
geometry: {
top: 100,
left: 200,
height: 30,
width: 40
}
}));
instance.resize({
height: 30,
width: 40,
top: 150,
left: 250
});
(0, _globals.expect)(instance.$element().css("top")).toBe("150px");
(0, _globals.expect)(instance.$element().css("left")).toBe("250px");
(0, _globals.expect)(instance.$element().css("height")).toBe("30px");
(0, _globals.expect)(instance.$element().css("width")).toBe("40px")
})
});
(0, _globals.describe)("Text", () => {
_globals.it.each([{
isCompact: true,
expectedText: "1"
}, {
isCompact: false,
expectedText: "1 more"
}])("should have correct text for single appointment and isCompact = %o", _ref => {
let {
isCompact: isCompact,
expectedText: expectedText
} = _ref;
const instance = (0, _appointment_collector.createAppointmentCollector)(Object.assign({}, (0, _appointment_collector.getAppointmentCollectorProperties)([defaultAppointmentData]), {
isCompact: isCompact
}));
const $buttonContent = instance.$element().find(".dx-button-content");
(0, _globals.expect)($buttonContent.text()).toBe(expectedText)
});
(0, _globals.it)("should have correct text for two appointments and isCompact = true", () => {
const instance = (0, _appointment_collector.createAppointmentCollector)(Object.assign({}, (0, _appointment_collector.getAppointmentCollectorProperties)([Object.assign({}, defaultAppointmentData), Object.assign({}, defaultAppointmentData)]), {
isCompact: true
}));
const $buttonContent = instance.$element().find(".dx-button-content");
(0, _globals.expect)($buttonContent.text()).toBe("2")
})
})
});