Код: Выделить всё
(function(factory) {
if (typeof define === "function" && define.amd) {
define(["jquery", "jquery-ui-dist"], factory);
} else {
factory(jQuery);
}
}(function( $ ){
$.extend($.ui, { multiDatesPicker: { version: "1.6.6" } });
...
// Workaround for #4055
// Add another global to avoid noConflict issues with inline event handlers
window['DP_jQuery_' + dpuuid] = $;
Мой тестовый файл
Код: Выделить всё
import 'jsdom-global/register.js'; // Automatically sets up and tears down JSDOM
import $ from 'jquery'; // Import jQuery
import { expect } from 'chai'; // Import chai for assertions
import 'jquery-ui/ui/widgets/datepicker.js'; // Import jQuery UI datepicker
import '../jquery-ui.multidatespicker.js'; // Import the multiDatesPicker plugin (adjust path if necessary)
describe('multiDatesPicker Initialization', function() {
before(function() {
// Make jQuery globally available
global.$ = global.jQuery = $;
window.$ = window.jQuery = $;
});
it('should initialize the multi-date picker correctly', function() {
const $input = $(''); // Create a jQuery input element
$('body').append($input); // Append it to the DOM
$input.multiDatesPicker(); // Initialize the multi-dates picker
expect($input.hasClass('hasDatepicker')).to.be.true; // Check if the datepicker is initialized
});
});
Подробнее здесь: https://stackoverflow.com/questions/790 ... ker-plugin