Hi,
I would like to know where to start or if it is even possible to test using QUnit an igCombo DOM element (created with MVC Helpers). I would like to test its datasource and some options if are enabled or not.
Any suggestions are highly appreciated,
Kind regards,
Zora
Hi Angel, Konstantin,
I am using jQuery 1.7.2, so 'ui-igCombo' property is not the issue. This function works fine, is just the QUnit test that fails:
function updateComboDatasource(data) { <-- function is in external javascript file var combo = $("#igCombo"); var comboOptions = combo.data('igCombo').options; <-- combo.data('igCombo') is undefined comboOptions.dataSource = data; combo.igCombo('dataBind');
}
Somehow the 'igCombo' element is not recognized like an element of DOM. How can I mock it?
Thank you for your help,
Alternatively, you can use a version of jQuery that does not include this breaking change - versions below 1.9.0
Thanks,
Angel
Hello Zora,
jQuery UI have changed the naming of their widgets in the latest versions so if your test crashes with this then you should try:
var comboOptions = combo.data('ui-igCombo').options;
Let us know if this works in your case!
Hi Angel,
Thank you very much for your help! I'm changing the dataset of a 'igCombo' element and I got this far with my test:
test("updateComboDatasource()", function () { var mockDatasource = [{Text: "OTP-test1", Value: "OTP-value1"}]; updateComboDatasource(mockDatasource ); var mockCombo = $("#igCombo").data('igCombo').options; var expectedData = mockCombo.dataSource;
equal(expectedData, data, 'Data has been updated');});
and the function to test is:
function updateComboDatasource(data) { var combo = $("#igCombo"); var comboOptions = combo.data('igCombo').options; <---- here the test crashes, "Unable to get value of the property 'options': object is null or undefined" comboOptions.dataSource = data; combo.igCombo('dataBind');}
Any help is highly appreciated... maybe I should have initialized the igCombo inside the test?
hey,
Let me know if you need any additional help with this. Thanks,