I’ve started using google js test and have become stuck trying to unit test the jquery selector below – actualy i want to check that the append function has been called but that requires a selector.
‘JQuery’ is the jQuery ($) object that i inject into a function.
JQuery('#' + containerElementId).append('some html');
I have created an object that I use as a mock for jQuery
this.jQuery = {
append: createMockFunction()
};
I would like to test that append is called:
expectCall(this.jQuery(_).append)();
-OR-
expectCall(this.jQuery('#fakeselector').append)();
This gives me the error:
TypeError: Property ‘jQuery’ of object # is not a function
FAILED
What do i need to do to the this.jQuery object literal to get around the selector?
Discovered that you can create a mock like this: