HZGN.COM
welcome to my space
X
Welcome to:hzgn.com
Search:  
Feng Shui | Graphic Design | Cosmetics | Causes and Organizations | Regulatory Compliance | Gadgets and Gizmos | Computer Forensics | Tools and Equipment | Related articles
NAVIGATION - HOME

How to unit test Ext.Ajax (no server required)

Published by: webmaster 2009-01-08

All of my server code (PHP) has been developed using TDD, so I write unit tests first. I've been experimenting with ways to do this on the client, and the current SVN version of jsUnit has just answered my prayers.

ux.Media[.Flash] Comp,Panel,Win 2.0[new] [Archive] - Ext JS Forums::
no reason why I should need to make another trip to the server to get data that Ext.Ajax.request{ url:getFlashConfig.php ,success:function(response)
http://extjs.com/forum/archive/index.php/t-23983.html
HOME

I can now mock the Ajax response of an Ext.Ajax.request() call, allowing me to test server responses without ever involving the server.

I've posted a very basic example below - it doesn't actually test anything as it's just a simple demo, but coupled with jsUnit's MockTimeout it's really powerful.
Sr. Software Developer::
8+ software design and implementation but also includes unit/feature Involved in requirements, design, implementation, test, and support
http://www.computerjobs.com/job_display.aspx?jobid=2148988&siteid7917833&page=1&published=
HOME
Ajaxian PHP::
New unit test library. the cake: Ajax actions have no layout by default. also use an Ajax connection to grab data from the backend server and a little
http://ajaxian.com/by/topic/php/page/2
HOME

I hope someone else finds this as useful as I have:
KaBlog / Actiontastic::
add-on to integrate GWT with Ext. Unit test support. Google. browser app, compiled down to a single page AJAX app talks to this No extra username and
http://kaboomerang.com/blog/category/actiontastic
HOME
TestingStuff.com - Software Quality Tools::
the minimum number of test cases required to certify 100% of No software to install or web server to maintain. Call 508-281-5404. Bug Database Homepage
http://www.testingstuff.com/tools.html
HOME

Dan


var mockRequest;

function showResponse(conn, response, options) {
alert(response.responseText);
}

function setUp() {
mockRequest = createXmlHttpRequest();
//override Ext.lib.Ajax to use mockRequest
Ext.lib.Ajax.createXhrObject = function(transactionId) {
return{conn:mockRequest, tId:transactionId};
}
Ext.Ajax.on('requestcomplete',showResponse);
}

function testExtAjaxCall() {
//mock the response
mockRequest.responseText = "{id:4,login:'danh2000',name:'dan'}";
mockRequest.readyState = 4;
mockRequest.status = 200;
//send the request
Ext.Ajax.request({url:'dummy', params:{cmd:'GetUserDetails'} } );
}


Red Hat's Rough Recovery From CFO Exit
Windows Live Finds a New, Pre-installed Home

PRINT Add to favorites
#If you have any other info about this subject , Please add it free.#
Your name:
E-mail:
Telphone:

Your comments:


If you have any other info about How to unit test Ext.Ajax (no server required) , Please add it free.
About us |Contact us |Advertisement |Site map |Exchange links
Copyright© 2008hzgn.com All Rights Reserved