How to mock .each and .find method in jQuery using Jack?
I'm currently trying to mock the following method using Jack. The code example is 开发者_运维百科as below:
var ID = "id";
$('#' + ID + ' > div > table').each(function) {
var nodeSpan = $(this).find('span.' + NODE_INDICATORS)[0];
.
.
.
});
How should I approach it? Are there jQuery/QUnit functions that allows me to create a DOM node/element which I can use to mock the find method? Or can this be done easily with Jack?
Thanks.
If all you want to do is make nodes as part of your test, you can just use the HTML "signature" of the jQuery method; for instance:
$(someNode).append("<DIV id='55'>I'm a DIV!</DIV>");
If that's not what you're trying to do, maybe try to explain your question better?
I ended up supplying a DOM structure to pass the jquery code instead of mocking it.
精彩评论