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
|
@ -1,35 +1,35 @@
|
|||||||
/*
|
/*
|
||||||
Jasmine-Ajax : a set of helpers for testing AJAX requests under the Jasmine
|
Jasmine-Ajax : a set of helpers for testing AJAX requests under the Jasmine
|
||||||
BDD framework for JavaScript.
|
BDD framework for JavaScript.
|
||||||
|
|
||||||
Supports both Prototype.js and jQuery.
|
Supports both Prototype.js and jQuery.
|
||||||
|
|
||||||
http://github.com/pivotal/jasmine-ajax
|
http://github.com/pivotal/jasmine-ajax
|
||||||
|
|
||||||
Jasmine Home page: http://pivotal.github.com/jasmine
|
Jasmine Home page: http://pivotal.github.com/jasmine
|
||||||
|
|
||||||
Copyright (c) 2008-2010 Pivotal Labs
|
Copyright (c) 2008-2010 Pivotal Labs
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
"Software"), to deal in the Software without restriction, including
|
"Software"), to deal in the Software without restriction, including
|
||||||
without limitation the rights to use, copy, modify, merge, publish,
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
distribute, sublicense, and/or sell copies of the Software, and to
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
permit persons to whom the Software is furnished to do so, subject to
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
the following conditions:
|
the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
The above copyright notice and this permission notice shall be
|
||||||
included in all copies or substantial portions of the Software.
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Jasmine-Ajax interface
|
// Jasmine-Ajax interface
|
||||||
var ajaxRequests = [];
|
var ajaxRequests = [];
|
||||||
@ -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