Permalink
Browse files

Adding tests for features to be implemented

  • Loading branch information...
markstory committed Mar 7, 2009
1 parent 1c2cd94 commit ea177fb7d8f25c21bcb324c1e35191f1e779d2fd
Showing with 41 additions and 0 deletions.
  1. +41 −0 cake/tests/cases/libs/view/helpers/js.test.php
@@ -26,6 +26,7 @@
*/
App::import('Helper', 'Js');
+Mock::generate('Helper', 'TestJsEngineHelper', array('methodOne'));
/**
* JsHelper TestCase.
*
@@ -51,6 +52,36 @@ function startTest() {
function endTest() {
unset($this->Js);
}
+/**
+ * test object construction
+ *
+ * @return void
+ **/
+ function testConstruction() {
+ $js = new JsHelper();
+ $this->assertEqual($js->helpers, array('jqueryEngine'));
+
+ $js = new JsHelper(array('mootools'));
+ $this->assertEqual($js->helpers, array('mootoolsEngine'));
+
+ $js = new JsHelper('prototype');
+ $this->assertEqual($js->helpers, array('prototypeEngine'));
+
+ $js = new JsHelper('MyPlugin.Dojo');
+ $this->assertEqual($js->helpers, array('MyPlugin.DojoEngine'));
+ }
+/**
+ * test that methods dispatch internally and to the engine class
+ *
+ * @return void
+ **/
+ function testMethodDispatching() {
+ $js = new JsHelper(array('TestJs'));
+ $js->TestJsEngine = new TestJsEngineHelper();
+ $js->TestJsEngine->expectOnce('dispatchMethod', array('methodOne', array()));
+
+ $js->methodOne();
+ }
/**
* test escape string skills
*
@@ -123,6 +154,16 @@ function testConfirm() {
$expected = 'confirm("\"Are you sure?\"");';
$this->assertEqual($result, $expected);
}
+/**
+ * test Redirect
+ *
+ * @return void
+ **/
+ function testRedirect() {
+ $result = $this->Js->redirect(array('controller' => 'posts', 'action' => 'view', 1));
+ $expected = 'window.location = "/posts/view/1";';
+ $this->assertEqual($result, $expected);
+ }
}
?>

0 comments on commit ea177fb

Please sign in to comment.