hellojs-xiaotian
Version:
A clientside Javascript library for standardizing requests to OAuth2 web services (and OAuth1 - with a shim)
41 lines (28 loc) • 615 B
JavaScript
define([], function() {
var utils = hello.utils;
describe('utils.request', function() {
// Stub utils/xhr
var xhr = utils.xhr;
afterEach(function() {
utils.xhr = xhr;
});
it('should by default use a XMLHttpRequest', function() {
var p = {
url: '/localrequest'
};
var spy = sinon.spy(function() {
return {};
});
// Implicitly undefined
utils.xhr = spy;
utils.request(p);
expect(spy.called).to.be.ok();
spy.reset();
// Explicitly undefined
p.xhr = undefined;
utils.xhr = spy;
utils.request(p);
expect(spy.called).to.be.ok();
});
});
});