pull jquery and prototype mocks into named functions

master
Hunter Gillane 13 years ago
parent 9536fe9d02
commit 26e475dfb2

@ -0,0 +1,6 @@
pairs:
hg: Hunter Gillane
email:
prefix: pair
domain: pivotallabs.com

@ -151,11 +151,7 @@ jasmine.Ajax = {
installJquery: function() {
jasmine.Ajax.mode = 'jQuery';
jasmine.Ajax.real = jQuery.ajaxSettings.xhr;
jQuery.ajaxSettings.xhr = function() {
var newXhr = new FakeXMLHttpRequest();
ajaxRequests.push(newXhr);
return newXhr;
}
jQuery.ajaxSettings.xhr = jasmine.Ajax.jQueryMock;
},
@ -163,9 +159,7 @@ jasmine.Ajax = {
jasmine.Ajax.mode = 'Prototype';
jasmine.Ajax.real = Ajax.getTransport;
Ajax.getTransport = function() {
return new FakeXMLHttpRequest();
};
Ajax.getTransport = jasmine.Ajax.prototypeMock;
},
uninstallMock: function() {
@ -184,6 +178,16 @@ jasmine.Ajax = {
jasmine.Ajax.real = null;
},
jQueryMock: function() {
var newXhr = new FakeXMLHttpRequest();
ajaxRequests.push(newXhr);
return newXhr;
},
prototypeMock: function() {
return new FakeXMLHttpRequest();
},
installed: false,
mode: null
}

@ -39,7 +39,7 @@ describe("jasmine.Ajax", function() {
it("installs the mock", function() {
withoutPrototype(function() {
jasmine.Ajax.installMock();
expect(jQuery.ajaxSettings.xhr).toBe(FakeXMLHttpRequest);
expect(jQuery.ajaxSettings.xhr).toBe(jasmine.Ajax.jQueryMock);
});
});
@ -63,7 +63,7 @@ describe("jasmine.Ajax", function() {
it("installs the mock", function() {
withoutJquery(function() {
jasmine.Ajax.installMock();
expect(Ajax.getTransport).toBe(FakeXMLHttpRequest);
expect(Ajax.getTransport).toBe(jasmine.Ajax.prototypeMock);
});
});

Loading…
Cancel
Save