pull jquery and prototype mocks into named functions

This commit is contained in:
Hunter Gillane 2011-08-07 14:20:37 -06:00
parent 9536fe9d02
commit 26e475dfb2
4 changed files with 49 additions and 39 deletions

6
.pairs Normal file
View File

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

View File

@ -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
}

View File

@ -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);
});
});