I'm using jasmine for my unit tests. I have a function that contains:
var startDate = $("#startDate").data("kendoDatePicker").value();
But when the unit test hits that line it errors out saying:
TypeError: Cannot read property 'value' of null
I've tried stuff like setting it
$("#startDate").data("kendoDatePicker").value = '12/25/2014';
but that results in "cannot set value of null"(or something along those lines)
and I've tried to spy on it, but in all honesty, my knowledge here is limited. I'm hoping I'm just missing some basic terminology in my google searches and someone will be able to help me.
How do I mock this or spy on it?
Thanks in advance!
EDIT:
I was able to "fix" it but I consider this "hacky" and would still like a better solution. I created a new html page called "tests.html" which contains:
<div style="visibility: hidden; height: 0">
<input id="startDate" />
</div>
Then I referenced the file:
/// <reference path="tests.html" />
Then at the top of my unit test I added:
$('#startDate').kendoDatePicker({
min: new Date()
});
And now it "works", but it's reading from an actual input box, which it shouldn't need...