Skip to content

Commit

Permalink
Adding test cases for alert, confirm, prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Mar 7, 2009
1 parent c92cfa7 commit 1c2cd94
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions cake/tests/cases/libs/view/helpers/js.test.php
Expand Up @@ -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.