0

I have a function like:

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

How do I create 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);
    });
};
Noel Yap
  • 18,822
  • 21
  • 92
  • 144
  • *Warning: Shameless self plug*. You could try [Myrtle](http://spadgos.com/?p=67) as a mocking framework. ;) – nickf Aug 16 '11 at 23:16
  • Myrtle looks pretty good, but it looks like it can't verify expectations (eg verify that specific functions were called). – Noel Yap Aug 16 '11 at 23:24
  • that's true. (Right now) it just tracks usage of functions, but you could use its output in whatever testing framework you want. It's obviously a very new project, so I'd be interested to hear what other functions you think it could use. – nickf Aug 17 '11 at 08:33
  • I started looking into using Sinon.js until I realized that mocking frameworks may not be needed for angular testing. – Noel Yap Aug 17 '11 at 16:19

0 Answers0