pull jquery and prototype mocks into named functions
This commit is contained in:
parent
9536fe9d02
commit
26e475dfb2
6
.pairs
Normal file
6
.pairs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
pairs:
|
||||||
|
hg: Hunter Gillane
|
||||||
|
|
||||||
|
email:
|
||||||
|
prefix: pair
|
||||||
|
domain: pivotallabs.com
|
@ -151,11 +151,7 @@ jasmine.Ajax = {
|
|||||||
installJquery: function() {
|
installJquery: function() {
|
||||||
jasmine.Ajax.mode = 'jQuery';
|
jasmine.Ajax.mode = 'jQuery';
|
||||||
jasmine.Ajax.real = jQuery.ajaxSettings.xhr;
|
jasmine.Ajax.real = jQuery.ajaxSettings.xhr;
|
||||||
jQuery.ajaxSettings.xhr = function() {
|
jQuery.ajaxSettings.xhr = jasmine.Ajax.jQueryMock;
|
||||||
var newXhr = new FakeXMLHttpRequest();
|
|
||||||
ajaxRequests.push(newXhr);
|
|
||||||
return newXhr;
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -163,9 +159,7 @@ jasmine.Ajax = {
|
|||||||
jasmine.Ajax.mode = 'Prototype';
|
jasmine.Ajax.mode = 'Prototype';
|
||||||
jasmine.Ajax.real = Ajax.getTransport;
|
jasmine.Ajax.real = Ajax.getTransport;
|
||||||
|
|
||||||
Ajax.getTransport = function() {
|
Ajax.getTransport = jasmine.Ajax.prototypeMock;
|
||||||
return new FakeXMLHttpRequest();
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
|
||||||
uninstallMock: function() {
|
uninstallMock: function() {
|
||||||
@ -184,6 +178,16 @@ jasmine.Ajax = {
|
|||||||
jasmine.Ajax.real = null;
|
jasmine.Ajax.real = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
jQueryMock: function() {
|
||||||
|
var newXhr = new FakeXMLHttpRequest();
|
||||||
|
ajaxRequests.push(newXhr);
|
||||||
|
return newXhr;
|
||||||
|
},
|
||||||
|
|
||||||
|
prototypeMock: function() {
|
||||||
|
return new FakeXMLHttpRequest();
|
||||||
|
},
|
||||||
|
|
||||||
installed: false,
|
installed: false,
|
||||||
mode: null
|
mode: null
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ describe("jasmine.Ajax", function() {
|
|||||||
it("installs the mock", function() {
|
it("installs the mock", function() {
|
||||||
withoutPrototype(function() {
|
withoutPrototype(function() {
|
||||||
jasmine.Ajax.installMock();
|
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() {
|
it("installs the mock", function() {
|
||||||
withoutJquery(function() {
|
withoutJquery(function() {
|
||||||
jasmine.Ajax.installMock();
|
jasmine.Ajax.installMock();
|
||||||
expect(Ajax.getTransport).toBe(FakeXMLHttpRequest);
|
expect(Ajax.getTransport).toBe(jasmine.Ajax.prototypeMock);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user