From 1c2cd947863f7d0fcd11966f97bc0d8636c5b490 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 6 Mar 2009 19:56:28 -0500 Subject: [PATCH] Adding test cases for alert, confirm, prompt --- .../tests/cases/libs/view/helpers/js.test.php | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/cake/tests/cases/libs/view/helpers/js.test.php b/cake/tests/cases/libs/view/helpers/js.test.php index a362aaa86..a5053d570 100644 --- a/cake/tests/cases/libs/view/helpers/js.test.php +++ b/cake/tests/cases/libs/view/helpers/js.test.php @@ -81,6 +81,48 @@ class JsHelperTestCase extends CakeTestCase { $expected = 'my \\\"string\\\"'; $this->assertEqual($result, $expected); } +/** + * test prompt() creation + * + * @return void + **/ + function testPrompt() { + $result = $this->Js->prompt('Hey, hey you', 'hi!'); + $expected = 'prompt("Hey, hey you", "hi!");'; + $this->assertEqual($result, $expected); + + $result = $this->Js->prompt('"Hey"', '"hi"'); + $expected = 'prompt("\"Hey\"", "\"hi\"");'; + $this->assertEqual($result, $expected); + } +/** + * test alert generation + * + * @return void + **/ + function testAlert() { + $result = $this->Js->alert('Hey there'); + $expected = 'alert("Hey there");'; + $this->assertEqual($result, $expected); + + $result = $this->Js->alert('"Hey"'); + $expected = 'alert("\"Hey\"");'; + $this->assertEqual($result, $expected); + } +/** + * test confirm generation + * + * @return void + **/ + function testConfirm() { + $result = $this->Js->confirm('Are you sure?'); + $expected = 'confirm("Are you sure?");'; + $this->assertEqual($result, $expected); + + $result = $this->Js->confirm('"Are you sure?"'); + $expected = 'confirm("\"Are you sure?\"");'; + $this->assertEqual($result, $expected); + } } ?> \ No newline at end of file