开发者

How to mock $xhr with Jack?

开发者 https://www.devze.com 2023-03-28 08:41 出处:网络
I have a function like: function Aoeu($xhr) { $xhr(\'GET\', \'/url\', function(code, response) {}); }; How do I crea开发者_开发技巧te with Jack a $xhr mock that\'s to be passed into Aoeu()?

I have a function like:

function Aoeu($xhr) {
    $xhr('GET', '/url', function(code, response) {});
};

How do I crea开发者_开发技巧te with Jack a $xhr mock that's to be passed into Aoeu()?

The following says that the mock is an object, not a function (which makes sense):

AoeuTest.prototype.testAoeu = function() {
    jack(function() {
        var xhrStub = jack.create('$xhr', ['']);

//        jack.expect('$xhr');

        var aoeu = new Aoeu(xhrStub);
    });
};
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号