Namespace TH.Ajax
This mocks out Prototype's ajax calls so that you don't need a server in your tests
Defined in: screw.mock.js.
Constructor Attributes | Constructor Name and Description |
---|---|
This mocks out Prototype's ajax calls so that you don't need a server in your tests
|
Field Attributes | Field Name and Description |
---|---|
<static> |
TH.Ajax.requestCount
Lets you count the number of requests on a certain URL
|
Method Attributes | Method Name and Description |
---|---|
<static> |
TH.Ajax.mock(urlToMock, response, status)
this is the main mocking interface
|
<static> |
TH.Ajax.reset()
Reset the request count - used in a before()
|
Namespace Detail
TH.Ajax
This mocks out Prototype's ajax calls so that you don't need a server in your tests
TH.Ajax.mock("/a_url", "someText", 200); var ajx = new Ajax.Request("/a_url", { onComplete: function (resp) { response = resp } }); expect(response.responseText).to(equal, "someText");
Field Detail
<static>
TH.Ajax.requestCount
Lets you count the number of requests on a certain URL
TH.Ajax.mock("/a_url", "someText", 200); var ajx = new Ajax.Request("/a_url", { onComplete: function (resp) { response = resp } }); expect(TH.Ajax.requestCont["/a_url"]).to(equal, 1);
Method Detail
<static>
TH.Ajax.mock(urlToMock, response, status)
this is the main mocking interface
TH.Ajax.mock("/a_url", "someText", 200); var ajx = new Ajax.Request("/a_url", { onComplete: function (resp) { response = resp } }); expect(response.responseText).to(equal, "someText");
- Parameters:
- {String} urlToMock
- the url that you want to respond with your response
- {String} response
- the text you want the server to send back. Text will try to be evaled into JSON so that responseJSON can be set.
- {Number} status
- (optional) the response code you want the server to send
<static>
TH.Ajax.reset()
Reset the request count - used in a before()