Skip to content

Commit

Permalink
Added test case for JqueryEngineHelper::request() to validate 'xhr' c…
Browse files Browse the repository at this point in the history
…allback.
  • Loading branch information
cameri committed Oct 18, 2013
1 parent bb33d52 commit 069b309
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/Cake/Test/Case/View/Helper/JqueryEngineHelperTest.php
Expand Up @@ -219,6 +219,17 @@ public function testRequest() {
));
$expected = '$.ajax({beforeSend:function (XMLHttpRequest) {doBefore}, data:$("#someId").serialize(), success:function (data, textStatus) {doFoo}, type:"post", url:"\\/people\\/edit\\/1"});';
$this->assertEquals($expected, $result);

$result = $this->Jquery->request('/people/edit/1', array(
'success' => 'doFoo',
'xhr' => 'return jQuery.ajaxSettings.xhr();',
'async' => true,
'method' => 'post',
'dataExpression' => true,
'data' => '$("#someId").serialize()',
));
$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();}});';
$this->assertEquals($expected, $result);
}

/**
Expand Down

0 comments on commit 069b309

Please sign in to comment.