Skip to content
Permalink
Browse files

Adding test cases for alert, confirm, prompt

  • Loading branch information...
markstory committed Mar 7, 2009
1 parent c92cfa7 commit 1c2cd947863f7d0fcd11966f97bc0d8636c5b490
Showing with 42 additions and 0 deletions.
  1. +42 −0 cake/tests/cases/libs/view/helpers/js.test.php
@@ -81,6 +81,48 @@ function testEscaping() {
$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);
}
}
?>

0 comments on commit 1c2cd94

Please sign in to comment.
You can’t perform that action at this time.