(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] = $;
Я пытаюсь написать модульные тесты для этого плагина, но постоянно получаю эту ошибку. Исключение во время выполнения: ReferenceError: jQuery не определенв среде NodeJS. Обратите внимание, что у меня нет html-файла, в котором можно использовать puglin. Мой тестовый файл
... // Workaround for #4055 // Add another global to avoid noConflict issues with inline event handlers window['DP_jQuery_' + dpuuid] = $;
[/code] Я пытаюсь написать модульные тесты для этого плагина, но постоянно получаю эту ошибку. Исключение во время выполнения: ReferenceError: jQuery не определенв среде NodeJS. Обратите внимание, что у меня нет html-файла, в котором можно использовать puglin. [b]Мой тестовый файл[/b] [code]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)
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 });
}); [/code] Буду признателен за любую помощь. Спасибо