Skip to content

Instantly share code, notes, and snippets.

@nerevar
Created January 12, 2016 17:25
Show Gist options
  • Save nerevar/f96131f86f05cf4f5931 to your computer and use it in GitHub Desktop.
Save nerevar/f96131f86f05cf4f5931 to your computer and use it in GitHub Desktop.
it.only('должен вызывать _onSuccess при заданных параметрах', function(done) {
// TODO: 2. sinon ajax request
block = BEM.create('i-request_type_bem', { url: '/qwer' });
sinon.stub(block, '_getArgs').returns({});
sinon.stub(block, '_onSuccess', function(a, b, c, d) {
console.log('success', a,b,c,d);
done();
});
sinon.stub(block, '_onError', function(a, b, c, d) {
console.log('error', a,b,c,d);
done();
});
var server = sinon.fakeServer.create();
server.respondWith("GET", "/qwer",
[200, { "Content-Type": "application/json" },
'[{ "id": 12, "comment": "Hey there" }]']);
block.get();
server.respond();
server.restore();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment