Skip to content

Commit 069b309

Browse files
committed
Added test case for JqueryEngineHelper::request() to validate 'xhr' callback.
1 parent bb33d52 commit 069b309

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/Cake/Test/Case/View/Helper/JqueryEngineHelperTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,17 @@ public function testRequest() {
219219
));
220220
$expected = '$.ajax({beforeSend:function (XMLHttpRequest) {doBefore}, data:$("#someId").serialize(), success:function (data, textStatus) {doFoo}, type:"post", url:"\\/people\\/edit\\/1"});';
221221
$this->assertEquals($expected, $result);
222+
223+
$result = $this->Jquery->request('/people/edit/1', array(
224+
'success' => 'doFoo',
225+
'xhr' => 'return jQuery.ajaxSettings.xhr();',
226+
'async' => true,
227+
'method' => 'post',
228+
'dataExpression' => true,
229+
'data' => '$("#someId").serialize()',
230+
));
231+
$expected = '$.ajax({async:true, data:$("#someId").serialize(), success:function (data, textStatus) {doFoo}, type:"post", url:"\/mpm\/people\/edit\/1", xhr:function () {return jQuery.ajaxSettings.xhr();}});';
232+
$this->assertEquals($expected, $result);
222233
}
223234

224235
/**

0 commit comments

Comments
 (0)