Adding AjaxHelper tests

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4458 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2007-02-06 14:23:36 +00:00
parent 825897cd39
commit 454d9716d2

View file

@ -47,6 +47,18 @@ class AjaxTest extends UnitTestCase {
$this->ajax->Javascript = new JavascriptHelper(); $this->ajax->Javascript = new JavascriptHelper();
} }
function testEvalScripts() {
$result = $this->ajax->link('Test Link', '/', array('id' => 'link1', 'update' => 'content', 'evalScripts' => false));
$expected = '<a href="/" id="link1" onclick=" return false;">Test Link</a><script type="text/javascript">Event.observe(\'link1\', \'click\', function(event){ new Ajax.Updater(\'content\',\'/\', {asynchronous:true, evalScripts:false, requestHeaders:[\'X-Update\', \'content\']}) }, false);</script>';
$this->assertEqual($result, $expected);
}
function testAsynchronous() {
$result = $this->ajax->link('Test Link', '/', array('id' => 'link1', 'update' => 'content', 'type' => 'synchronous'));
$expected = '<a href="/" id="link1" onclick=" return false;">Test Link</a><script type="text/javascript">Event.observe(\'link1\', \'click\', function(event){ new Ajax.Updater(\'content\',\'/\', {asynchronous:false, evalScripts:true, requestHeaders:[\'X-Update\', \'content\']}) }, false);</script>';
$this->assertEqual($result, $expected);
}
function testDraggable() { function testDraggable() {
$result = $this->ajax->drag('id', array('handle' => 'other_id')); $result = $this->ajax->drag('id', array('handle' => 'other_id'));
$expected = '<script type="text/javascript">new Draggable(\'id\', {handle:\'other_id\'});</script>'; $expected = '<script type="text/javascript">new Draggable(\'id\', {handle:\'other_id\'});</script>';