I wrote the code below, try to check if the jquery dialog will apologize and display.
var jqueryMock = sinon.mock(jQuery);
var dialogExpectation = jqueryMock.expects("dialog");
dialogExpectation.once();
equals(dialogExpectation.verify(), true, "Dialog is displayed");
jqueryMock.restore();
However, this shows me an error: Died in test # 1: Trying to wrap the undefined properties dialog as a function - {"message": "Attempting to wrap the undefined properties dialog as a function", "name": "TypeError"}
The jquery code is very simple:
displayMessage: function (message, title, hashId) {
$(messageDiv).dialog({
height: 240,
width: 375,
modal: true,
title: title,
resizable: false,
buttons: [{
text: localizedErrorMessages['OkText'],
click: function () {
$(this).dialog("close");
}
}]
});
}
Does anyone know how to trick the jquery dialog and write unit test in this script?
source
share